Created
October 27, 2019 16:22
-
-
Save CliffordAnderson/a11b7836547f2b57126e6c52251482d8 to your computer and use it in GitHub Desktop.
Sample neovis.js page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>Neovis.js Simple Example</title> | |
<style type="text/css"> | |
html, body { | |
font: 16pt arial; | |
} | |
#viz { | |
width: 900px; | |
height: 700px; | |
border: 1px solid lightgray; | |
font: 22pt arial; | |
} | |
</style> | |
<script src="https://cdn.neo4jlabs.com/neovis.js/v1.2.1/neovis.js"></script> | |
<script | |
src="https://code.jquery.com/jquery-3.2.1.min.js" | |
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" | |
crossorigin="anonymous"></script> | |
<script type="text/javascript"> | |
// define config car | |
// instantiate nodevis object | |
// draw | |
var viz; | |
function draw() { | |
var config = { | |
container_id: "viz", | |
server_url: "bolt://3.133.1.31/:7687", | |
server_user: "neo4j", | |
server_password: "neo4j", | |
labels: { | |
//"Station": "name", | |
"Station": { | |
"caption": "name", | |
"size": "pagerank", | |
"community": "community" | |
//"sizeCypher": "MATCH (n) WHERE id(n) = {id} MATCH (n)-[r]-() RETURN sum(r.weight) AS c" | |
} | |
}, | |
relationships: { | |
"Line": { | |
"thickness": "weight", | |
"caption": false | |
} | |
}, | |
initial_cypher: "MATCH (a:Station {name:'Bahnhof Berlin Potsdamer Platz'}),(c:Station {name:'U-Bahnhof Alt-Tegel'}), p = shortestPath((a)-[:Line*]-(c)) RETURN p" | |
}; | |
viz = new NeoVis.default(config); | |
viz.render(); | |
console.log(viz); | |
} | |
</script> | |
</head> | |
<body onload="draw()"> | |
<div id="viz"></div> | |
Cypher query: <textarea rows="4" cols=50 id="cypher"></textarea><br> | |
<input type="submit" value="Submit" id="reload"> | |
<input type="submit" value="Stabilize" id="stabilize"> | |
</body> | |
<script> | |
$("#reload").click(function() { | |
var cypher = $("#cypher").val(); | |
if (cypher.length > 3) { | |
viz.renderWithCypher(cypher); | |
} else { | |
console.log("reload"); | |
viz.reload(); | |
} | |
}); | |
$("#stabilize").click(function() { | |
viz.stabilize(); | |
}) | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment