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.

104 lines
2.6 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>Graph2d | Basic demo</title>
  5. <style type="text/css">
  6. body, html {
  7. font-family: sans-serif;
  8. }
  9. </style>
  10. <script src="../../dist/vis.js"></script>
  11. <link href="../../dist/vis.css" rel="stylesheet" type="text/css" />
  12. </head>
  13. <body>
  14. <div id="visualization"></div>
  15. <script type="text/javascript">
  16. var options = {
  17. yAxisOrientation: 'left',
  18. shaded: {
  19. enabled: true,
  20. orientation: 'bottom' // top, bottom
  21. },
  22. drawPoints: {
  23. enabled: false,
  24. size: 6,
  25. style: 'circle' // square, circle
  26. }
  27. };
  28. // create a data set with groups
  29. var names = ['John', 'Alston', 'Lee', 'Grant'];
  30. var groups = new vis.DataSet();
  31. groups.add({
  32. id: 0,
  33. content: names[0],
  34. className: "graphGroup9",
  35. options: {
  36. drawPoints: {
  37. style: 'square' // square, circle
  38. },
  39. shaded: {
  40. orientation: 'bottom' // top, bottom
  41. }
  42. }});
  43. groups.add({
  44. id: 1,
  45. content: names[1],
  46. className: "graphGroup1",
  47. options: {
  48. yAxisOrientation: 'right',
  49. drawPoints: true, // square, circle
  50. shaded: {
  51. orientation: 'top' // top, bottom
  52. }
  53. }});
  54. groups.add({
  55. id: 2,
  56. content: names[2],
  57. className: "graphGroup2",
  58. options: {
  59. shaded: {
  60. enabled: false,
  61. orientation: 'top' // top, bottom
  62. }
  63. }});
  64. var container = document.getElementById('visualization');
  65. var items = [
  66. {x: '2014-06-11', y: 10 },
  67. {x: '2014-06-12', y: 25 },
  68. {x: '2014-06-13', y: 30, group: 0},
  69. {x: '2014-06-14', y: 10, group: 0},
  70. {x: '2014-06-15', y: 150, group: 1},
  71. {x: '2014-06-16', y: 300, group: 1},
  72. {x: '2014-06-17', y: 100, group: 1},
  73. {x: '2014-06-18', y: 150, group: 1},
  74. {x: '2014-06-19', y: 520, group: 1},
  75. {x: '2014-06-20', y: 100, group: 1},
  76. {x: '2014-06-21', y: 19, group: 2},
  77. {x: '2014-06-22', y: 60, group: 2},
  78. {x: '2014-06-23', y: 10, group: 2},
  79. {x: '2014-06-24', y: 25, group: 2},
  80. {x: '2014-06-25', y: 30, group: 2}
  81. // {x: '2014-06-11', y: 10},
  82. // {x: '2014-06-12', y: 25},
  83. // {x: '2014-06-13', y: 30},
  84. // {x: '2014-06-14', y: 10},
  85. // {x: '2014-06-15', y: 15},
  86. // {x: '2014-06-16', y: 30}
  87. ];
  88. var dataset = new vis.DataSet(items);
  89. var graph2d = new vis.Graph2d(container);
  90. graph2d.setOptions(options);
  91. graph2d.setGroups(groups);
  92. graph2d.setItems(dataset);
  93. </script>
  94. </body>
  95. </html>