form-example.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Neovis.js Simple Example</title>
  5. <style type="text/css">
  6. html, body, input, textarea {
  7. font: 10pt arial;
  8. }
  9. #viz {
  10. width: 75%;
  11. height:700px;
  12. border: 1px solid lightgray;
  13. font: 22pt arial;
  14. margin: 10px;
  15. }
  16. label {
  17. display: inline-block;
  18. width: 10em;
  19. }
  20. </style>
  21. <script src="https://cdn.neo4jlabs.com/neovis.js/master/neovis.js"></script>
  22. <script
  23. src="https://code.jquery.com/jquery-3.2.1.min.js"
  24. integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
  25. crossorigin="anonymous"></script>
  26. <script type="text/javascript">
  27. var viz;
  28. function draw() {
  29. var config = {
  30. container_id: "viz",
  31. server_url: $("#url").val(),
  32. server_user: $("#user").val(),
  33. server_password: $("#pass").val(),
  34. labels: {},
  35. relationships: {},
  36. initial_cypher: $("#cypher").val()
  37. };
  38. config.labels[$("#label").val()] = {
  39. "caption": $("#caption").val(),
  40. "size": $("#size").val(),
  41. "community": $("#community").val(),
  42. //"sizeCypher": "MATCH (n) WHERE id(n) = {id} MATCH (n)-[r]-() RETURN sum(r.weight) AS c"
  43. };
  44. config.relationships[$("#rel_type").val()] = {
  45. "thickness": $("#thickness").val(),
  46. "caption": $("#rel_caption").val(),
  47. }
  48. viz = new NeoVis.default(config);
  49. viz.render();
  50. console.log(viz);
  51. }
  52. </script>
  53. </head>
  54. <body>
  55. <div id="viz" style="float:left"></div>
  56. <div>
  57. <div><h3>Connection Details:</h3>
  58. <label for="url">URL</label><input id="url" name="url" type="text" value="bolt://localhost:7687"/><br/>
  59. <label for="user">Username</label><input id="user" name="user" type="text" value="neo4j"/><br/>
  60. <label for="pass">Password</label><input id="pass" name="pass" type="password" value="test"/>
  61. </div>
  62. <div><h3>Styling Nodes:</h3>
  63. <label for="label">Node-Label</label><input id="label" name="label" type="text" value="Character"/><br/>
  64. <label for="caption">Label</label><input id="caption" name="caption" type="text" value="name"/><br/>
  65. <label for="size">Size</label><input id="size" name="size" type="text" value="pagerank"/><br/>
  66. <label for="color">Color</label><input id="community" name="community" type="text" value="community"/>
  67. </div>
  68. <div><h3>Styling Relationship:</h3>
  69. <label for="type">Relationship-Type</label><input id="type" name="type" type="text" value="INTERACTS"/><br/>
  70. <label for="thickness">Thickness</label><input id="thickness" name="thickness" type="text" value="weight"/><br/>
  71. <label for="rel_caption">Caption</label><input id="rel_caption" name="rel_caption" type="text" value=""/>
  72. </div>
  73. <div><h3>Cypher query: </h3>
  74. <textarea rows="4" cols=50 id="cypher">MATCH (n)-[r:INTERACTS]->(m) RETURN n,r,m</textarea><br>
  75. <input type="submit" value="Submit" id="reload">
  76. <input type="submit" value="Stabilize" id="stabilize">
  77. </div>
  78. </div>
  79. </body>
  80. <script>
  81. $(document).ready(function() {
  82. draw();
  83. })
  84. $("#reload").click(function() {
  85. draw();
  86. /*
  87. var cypher = $("#cypher").val();
  88. if (cypher.length > 3) {
  89. viz.renderWithCypher(cypher);
  90. } else {
  91. console.log("reload");
  92. viz.reload();
  93. }
  94. */
  95. });
  96. $("#stabilize").click(function() {
  97. viz.stabilize();
  98. })
  99. </script>
  100. </html>