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.

83 lines
2.4 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-network.min.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 svg = '<svg xmlns="http://www.w3.org/2000/svg" width="390" 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> am' +
  30. '<span style="color:white; text-shadow:0 0 20px #000000;">' +
  31. ' HTML in SVG!</span>' +
  32. '</div>' +
  33. '</foreignObject>' +
  34. '</svg>';
  35. var url = "data:image/svg+xml;charset=utf-8,"+ encodeURIComponent(svg);
  36. // Called when the Visualization API is loaded.
  37. function draw() {
  38. // Create a data table with nodes.
  39. nodes = [];
  40. // Create a data table with links.
  41. edges = [];
  42. nodes.push({id: 1, label: 'Get HTML', image: url, shape: 'image'});
  43. nodes.push({id: 2, label: 'Using SVG', image: url, shape: 'image'});
  44. edges.push({from: 1, to: 2, length: 300});
  45. // create a network
  46. var container = document.getElementById('mynetwork');
  47. var data = {
  48. nodes: nodes,
  49. edges: edges
  50. };
  51. var options = {
  52. physics: {stabilization: false},
  53. edges: {smooth: false}
  54. };
  55. network = new vis.Network(container, data, options);
  56. }
  57. </script>
  58. </head>
  59. <body onload="draw()">
  60. <p>
  61. This example demonstrates showing custom HTML in Nodes, by using an SVG image.
  62. </p>
  63. <p style="color: red;">
  64. WARNING: this is currently not supported by all browsers.
  65. </p>
  66. <div id="mynetwork"></div>
  67. </body>
  68. </html>