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.

102 lines
3.1 KiB

9 years ago
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Network | Circular images</title>
  5. <style type="text/css">
  6. body {
  7. font: 10pt arial;
  8. }
  9. #mynetwork {
  10. width: 800px;
  11. height: 800px;
  12. border: 1px solid lightgray;
  13. background-color:#333333;
  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 DIR = 'img/soft-scraps-icons/';
  20. var nodes = null;
  21. var edges = null;
  22. var network = null;
  23. // Called when the Visualization API is loaded.
  24. function draw() {
  25. // create people.
  26. // value corresponds with the age of the person
  27. var DIR = '../img/indonesia/';
  28. nodes = [
  29. {id: 1, shape: 'circularImage', image: DIR + '1.png'},
  30. {id: 2, shape: 'circularImage', image: DIR + '2.png'},
  31. {id: 3, shape: 'circularImage', image: DIR + '3.png'},
  32. {id: 4, shape: 'circularImage', image: DIR + '4.png', label:"pictures by this guy!"},
  33. {id: 5, shape: 'circularImage', image: DIR + '5.png'},
  34. {id: 6, shape: 'circularImage', image: DIR + '6.png'},
  35. {id: 7, shape: 'circularImage', image: DIR + '7.png'},
  36. {id: 8, shape: 'circularImage', image: DIR + '8.png'},
  37. {id: 9, shape: 'circularImage', image: DIR + '9.png'},
  38. {id: 10, shape: 'circularImage', image: DIR + '10.png'},
  39. {id: 11, shape: 'circularImage', image: DIR + '11.png'},
  40. {id: 12, shape: 'circularImage', image: DIR + '12.png'},
  41. {id: 13, shape: 'circularImage', image: DIR + '13.png'},
  42. {id: 14, shape: 'circularImage', image: DIR + '14.png'},
  43. {id: 15, shape: 'circularImage', image: DIR + 'missing.png', brokenImage: DIR + 'missingBrokenImage.png', label:"when images\nfail\nto load"},
  44. {id: 16, shape: 'circularImage', image: DIR + 'anotherMissing.png', brokenImage: DIR + '9.png', label:"fallback image in action"}
  45. ];
  46. // create connections between people
  47. // value corresponds with the amount of contact between two people
  48. edges = [
  49. {from: 1, to: 2},
  50. {from: 2, to: 3},
  51. {from: 2, to: 4},
  52. {from: 4, to: 5},
  53. {from: 4, to: 10},
  54. {from: 4, to: 6},
  55. {from: 6, to: 7},
  56. {from: 7, to: 8},
  57. {from: 8, to: 9},
  58. {from: 8, to: 10},
  59. {from: 10, to: 11},
  60. {from: 11, to: 12},
  61. {from: 12, to: 13},
  62. {from: 13, to: 14},
  63. {from: 9, to: 16}
  64. ];
  65. // create a network
  66. var container = document.getElementById('mynetwork');
  67. var data = {
  68. nodes: nodes,
  69. edges: edges
  70. };
  71. var options = {
  72. nodes: {
  73. borderWidth:4,
  74. size:30,
  75. color: {
  76. border: '#222222',
  77. background: '#666666'
  78. },
  79. font:{color:'#eeeeee'}
  80. },
  81. edges: {
  82. color: 'lightgray'
  83. }
  84. };
  85. network = new vis.Network(container, data, options);
  86. }
  87. </script>
  88. </head>
  89. <body onload="draw()">
  90. <div id="mynetwork"></div>
  91. </body>
  92. </html>