form-example.html 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. function draw() {
  53. // alert("inside method");
  54. var config = {
  55. container_id: "viz",
  56. server_url: "bolt://50.211.199.151:7687",
  57. server_user: "neo4j",
  58. server_password: "test",
  59. arrows: true,
  60. labels: {
  61. "Patent": {
  62. "caption": "patent_no"
  63. },
  64. "Application": {
  65. "caption": "application_no"
  66. },
  67. "Inventor": {
  68. "caption": "inventor_name"
  69. }
  70. },
  71. relationships: {
  72. },
  73. initial_cypher: "MATCH (n)-[r:CITES]->(m) RETURN n,r,m LIMIT 25"
  74. };
  75. viz = new NeoVis.default(config);
  76. console.log(JSON.stringify(viz));
  77. viz.render();
  78. console.log(viz)
  79. }
  80. </script>
  81. </head>
  82. <body>
  83. <div id="viz" style="float:left" onload="draw()" ></div>
  84. <!-- <div>
  85. <div><h3>Connection Details:</h3>
  86. <label for="url">URL</label><input id="url" name="url" type="text" value="bolt://localhost:7687"/><br/>
  87. <label for="user">Username</label><input id="user" name="user" type="text" value="neo4j"/><br/>
  88. <label for="pass">Password</label><input id="pass" name="pass" type="password" value="test"/>
  89. </div>
  90. <div><h3>Styling Nodes:</h3>
  91. <label for="label">Node-Label</label><input id="label" name="label" type="text" value="Character"/><br/>
  92. <label for="caption">Label</label><input id="caption" name="caption" type="text" value="name"/><br/>
  93. <label for="size">Size</label><input id="size" name="size" type="text" value="pagerank"/><br/>
  94. <label for="color">Color</label><input id="community" name="community" type="text" value="community"/>
  95. </div>
  96. <div><h3>Styling Relationship:</h3>
  97. <label for="type">Relationship-Type</label><input id="type" name="type" type="text" value="INTERACTS"/><br/>
  98. <label for="thickness">Thickness</label><input id="thickness" name="thickness" type="text" value="weight"/><br/>
  99. <label for="rel_caption">Caption</label><input id="rel_caption" name="rel_caption" type="text" value=""/>
  100. </div> -->
  101. <div><h3>Cypher query: </h3>
  102. <textarea rows="4" cols=50 id="cypher">MATCH (n)-[r:INTERACTS]->(m) RETURN n,r,m</textarea><br>
  103. <input type="submit" value="Submit" id="reload">
  104. <input type="submit" value="Stabilize" id="stabilize">
  105. </div>
  106. </div>
  107. </body>
  108. <script>
  109. $(document).ready(function() {
  110. draw();
  111. })
  112. $("#reload").click(function() {
  113. draw();
  114. /*
  115. var cypher = $("#cypher").val();
  116. if (cypher.length > 3) {
  117. viz.renderWithCypher(cypher);
  118. } else {
  119. console.log("reload");
  120. viz.reload();
  121. }
  122. */
  123. });
  124. $("#stabilize").click(function() {
  125. viz.stabilize();
  126. })
  127. </script>
  128. </html>