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.

85 lines
2.6 KiB

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Network | HTML in nodex</title>
  5. <style type="text/css">
  6. body {
  7. font: 10pt arial;
  8. }
  9. #mynetwork {
  10. width: 600px;
  11. height: 600px;
  12. border: 1px solid lightgray;
  13. background-color:#eeeeee;
  14. }
  15. </style>
  16. <script type="text/javascript" src="../../dist/vis.js"></script>
  17. <link href="../../dist/vis.css" rel="stylesheet" type="text/css" />
  18. <script type="text/javascript">
  19. var nodes = null;
  20. var edges = null;
  21. var network = null;
  22. var DIR = 'img/refresh-cl/';
  23. var LENGTH_MAIN = 150;
  24. var LENGTH_SUB = 50;
  25. var data = '<svg xmlns="http://www.w3.org/2000/svg" width="243" height="65">' +
  26. '<rect x="0" y="0" width="100%" height="100%" fill="#7890A7" stroke-width="20" stroke="#ffffff" ></rect>' +
  27. '<foreignObject x="15" y="10" width="100%" height="100%">' +
  28. '<div xmlns="http://www.w3.org/1999/xhtml" style="font-size:40px">' +
  29. '<em>I</em> like' +
  30. '<span style="color:white; text-shadow:0 0 20px #000000;">' +
  31. 'cheese</span>' +
  32. '</div>' +
  33. '</foreignObject>' +
  34. '</svg>';
  35. var DOMURL = window.URL || window.webkitURL || window;
  36. var img = new Image();
  37. var svg = new Blob([data], {type: 'image/svg+xml;charset=utf-8'});
  38. var url = DOMURL.createObjectURL(svg);
  39. // Called when the Visualization API is loaded.
  40. function draw() {
  41. // Create a data table with nodes.
  42. nodes = [];
  43. // Create a data table with links.
  44. edges = [];
  45. nodes.push({id: 1, label: 'Get HTML', image: url, shape: 'image'});
  46. nodes.push({id: 2, label: 'Using SVG', image: url, shape: 'image'});
  47. edges.push({from: 1, to: 2, length: 300});
  48. // create a network
  49. var container = document.getElementById('mynetwork');
  50. var data = {
  51. nodes: nodes,
  52. edges: edges
  53. };
  54. var options = {
  55. stabilize: false,
  56. smoothCurves:false
  57. };
  58. network = new vis.Network(container, data, options);
  59. }
  60. </script>
  61. </head>
  62. <body onload="draw()">
  63. <p>
  64. This example demonstrates showing custom HTML in Nodes, by using an SVG image.
  65. </p>
  66. <p style="color: red;">
  67. WARNING: this is currently not supported by all browsers.
  68. </p>
  69. <div id="mynetwork"></div>
  70. </body>
  71. </html>