form-example.html 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Neovis.js Simple Example</title>
  5. <style type="text/css">
  6. html,
  7. body,
  8. input,
  9. textarea {
  10. font: 10pt arial;
  11. }
  12. #viz {
  13. width: 75%;
  14. height: 700px;
  15. border: 1px solid lightgray;
  16. font: 22pt arial;
  17. margin: 10px;
  18. }
  19. label {
  20. display: inline-block;
  21. width: 10em;
  22. }
  23. </style>
  24. <script src="https://cdn.neo4jlabs.com/neovis.js/master/neovis.js"></script>
  25. <script src="https://code.jquery.com/jquery-3.2.1.min.js"
  26. integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
  27. <script type="text/javascript">
  28. var viz;
  29. // function draw() {
  30. // var config = {
  31. // container_id: "viz",
  32. // server_url: $("#url").val(),
  33. // server_user: $("#user").val(),
  34. // server_password: $("#pass").val(),
  35. // labels: {},
  36. // relationships: {},
  37. // initial_cypher: $("#cypher").val()
  38. // };
  39. // config.labels[$("#label").val()] = {
  40. // "caption": $("#caption").val(),
  41. // "size": $("#size").val(),
  42. // "community": $("#community").val(),
  43. // //"sizeCypher": "MATCH (n) WHERE id(n) = {id} MATCH (n)-[r]-() RETURN sum(r.weight) AS c"
  44. // };
  45. // config.relationships[$("#rel_type").val()] = {
  46. // "thickness": $("#thickness").val(),
  47. // "caption": $("#rel_caption").val(),
  48. // }
  49. // viz = new NeoVis.default(config);
  50. // viz.render();
  51. // console.log(viz);
  52. // }
  53. function draw() {
  54. // alert("inside method");
  55. var config = {
  56. container_id: "viz",
  57. server_url: "bolt://50.211.199.151:7687",
  58. server_user: "neo4j",
  59. server_password: "test",
  60. arrows: true,
  61. labels: {
  62. "Patent": {
  63. "caption": "patent_no"
  64. },
  65. "Application": {
  66. "caption": "application_no"
  67. },
  68. "Inventor": {
  69. "caption": "inventor_name"
  70. },
  71. "Case": {
  72. "captiton": "case_id"
  73. },
  74. "Court": {
  75. "caption": "court_id"
  76. },
  77. "Expert": {
  78. "caption": "expert_name"
  79. },
  80. "Firm": {
  81. "caption": "firm_name"
  82. },
  83. "Inventor": {
  84. "caption": "inventor_name"
  85. },
  86. "Party": {
  87. "caption": "party_name"
  88. },
  89. "Phrase": {
  90. "caption": "key_phrase"
  91. },
  92. "Acronym": {
  93. "caption": "acronym"
  94. },
  95. "Attorney": {
  96. "caption": "attorney_name"
  97. }
  98. },
  99. relationships: {
  100. },
  101. initial_cypher: "MATCH (n)-[r:CITES]->(m) RETURN n,r,m LIMIT 25"
  102. };
  103. viz = new NeoVis.default(config);
  104. console.log(JSON.stringify(viz));
  105. viz.render();
  106. console.log(viz)
  107. }
  108. </script>
  109. </head>
  110. <body>
  111. <div id="viz" style="float:left" onload="draw()"></div>
  112. <div>
  113. <h3>Cypher query: </h3>
  114. <textarea rows="4" cols=50 id="cypher">MATCH (n)-[r:INTERACTS]->(m) RETURN n,r,m</textarea><br>
  115. <input type="submit" value="Submit" id="reload">
  116. <input type="submit" value="Stabilize" id="stabilize">
  117. </div>
  118. </div>
  119. </body>
  120. <script>
  121. $(document).ready(function () {
  122. draw();
  123. })
  124. $("#reload").click(function () {
  125. draw();
  126. var cypher = $("#cypher").val();
  127. if (cypher.length > 3) {
  128. viz.renderWithCypher(cypher);
  129. } else {
  130. console.log("reload");
  131. viz.reload();
  132. }
  133. });
  134. $("#stabilize").click(function () {
  135. viz.stabilize();
  136. })
  137. </script>
  138. </html>