trolltweets.html 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Neovis.js Simple Example</title>
  5. <style type="text/css">
  6. html, body {
  7. font: 16pt arial;
  8. }
  9. #viz {
  10. width: 900px;
  11. height: 700px;
  12. border: 1px solid lightgray;
  13. font: 22pt arial;
  14. }
  15. </style>
  16. <!-- FIXME: load from dist -->
  17. <script type="text/javascript" src="https://rawgit.com/johnymontana/neovis.js/master/dist/neovis.js"></script>
  18. <script
  19. src="https://code.jquery.com/jquery-3.2.1.min.js"
  20. integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
  21. crossorigin="anonymous"></script>
  22. <script type="text/javascript">
  23. // define config car
  24. // instantiate nodevis object
  25. // draw
  26. var viz;
  27. function draw() {
  28. var config = {
  29. container_id: "viz",
  30. server_url: "bolt://localhost:7687",
  31. server_user: "neo4j",
  32. server_password: "letmein",
  33. labels: {
  34. "Tweet": {
  35. "caption": "text",
  36. "size": "retweets",
  37. "community": "community"
  38. },
  39. "Troll": {
  40. "caption": "screen_name",
  41. "size": "pagerank",
  42. "community": "community"
  43. }
  44. //"sizeCypher": "MATCH (n) WHERE id(n) = {id} MATCH (n)-[r]-() RETURN sum(r.weight) AS c"
  45. },
  46. relationships: {
  47. "AMPLIFIED": {
  48. "thickness": "count",
  49. "caption": false
  50. }
  51. },
  52. initial_cypher: "MATCH (n:Troll)-[r:AMPLIFIED]->(m:Troll) RETURN n,r,m LIMIT 500"
  53. };
  54. viz = new NeoVis.default(config);
  55. viz.render();
  56. console.log(viz);
  57. }
  58. </script>
  59. </head>
  60. <body onload="draw()">
  61. <div id="viz"></div>
  62. Cypher query: <textarea rows="4" cols=50 id="cypher"></textarea><br>
  63. <input type="submit" value="Submit" id="reload">
  64. <input type="submit" value="Stabilize" id="stabilize">
  65. </body>
  66. <script>
  67. $("#reload").click(function () {
  68. var cypher = $("#cypher").val();
  69. if (cypher.length > 3) {
  70. viz.renderWithCypher(cypher);
  71. } else {
  72. console.log("reload");
  73. viz.reload();
  74. }
  75. });
  76. $("#stabilize").click(function () {
  77. viz.stabilize();
  78. })
  79. </script>
  80. </html>