vis.js is a dynamic, browser-based visualization library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.5 KiB

  1. <html>
  2. <head>
  3. <title>Graph | Graphviz Gallery</title>
  4. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
  5. <script type="text/javascript" src="../../../vis.js"></script>
  6. <style type="text/css">
  7. p {
  8. width: 600px;
  9. }
  10. html, body, select {
  11. font: 11pt verdana;
  12. }
  13. #mygraph {
  14. width: 600px;
  15. height: 600px;
  16. border: 1px solid lightgray;
  17. }
  18. </style>
  19. </head>
  20. <body>
  21. <script>
  22. if (location.href.substr(0, 5) == 'file:') {
  23. document.write(
  24. '<p style="color: red;">' +
  25. 'Error: Cannot fetch the example data because of security ' +
  26. 'restrictions in JavaScript. Run the example from a server ' +
  27. 'instead of as a local file to resolve this problem. ' +
  28. 'Alternatively, you can load DOT graphs in ' +
  29. 'the <a href="../20_dot_language_playground.html" ' +
  30. 'style="color:red;">playground</a>.' +
  31. '</p>');
  32. }
  33. </script>
  34. <p>
  35. The following examples are unmodified copies from the
  36. <a href="http://www.graphviz.org/Gallery.php" target="_blank">Graphviz Gallery</a>.
  37. Note that vis.js does not support all attributes of Graphviz, and
  38. </p>
  39. <p>
  40. <label for="url">Select an example:</label>
  41. <select id="url" onchange="loadData()">
  42. <option value="data/fsm.gv.txt">fsm</option>
  43. <option value="data/hello.gv.txt">hello</option>
  44. <option value="data/process.gv.txt">process</option>
  45. <option value="data/siblings.gv.txt">siblings</option>
  46. <option value="data/softmaint.gv.txt">softmaint</option>
  47. <option value="data/traffic_lights.gv.txt">traffic_lights</option>
  48. <option value="data/transparency.gv.txt">transparency</option>
  49. <option value="data/twopi2.gv.txt">twopi2</option>
  50. <option value="data/unix.gv.txt">unix</option>
  51. <option value="data/world.gv.txt">world</option>
  52. </select>
  53. </p>
  54. <div id="mygraph"></div>
  55. <script type="text/javascript">
  56. var container = document.getElementById('mygraph');
  57. var url = document.getElementById('url');
  58. var graph = new vis.Graph(container);
  59. function loadData () {
  60. $.ajax({
  61. type: "GET",
  62. url: url.value
  63. }).done(function(data) {
  64. graph.setOptions({
  65. stabilize: false
  66. });
  67. graph.setData( {
  68. dot: data
  69. });
  70. });
  71. }
  72. loadData();
  73. </script>
  74. </body>
  75. </html>