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.

106 lines
2.7 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. style:'bar',
  49. yAxisOrientation: 'right',
  50. drawPoints: false, // square, circle
  51. shaded: {
  52. orientation: 'top' // top, bottom
  53. }
  54. }});
  55. groups.add({
  56. id: 2,
  57. content: names[2],
  58. className: "graphGroup2",
  59. options: {
  60. // yAxisOrientation: 'right',
  61. shaded: {
  62. enabled: false,
  63. orientation: 'top' // top, bottom
  64. }
  65. }});
  66. var container = document.getElementById('visualization');
  67. var items = [
  68. {x: '2014-06-11', y: 10 },
  69. {x: '2014-06-12', y: 25 },
  70. {x: '2014-06-13', y: 30, group: 0},
  71. {x: '2014-06-14', y: 10, group: 0},
  72. {x: '2014-06-15', y: 15, group: 1},
  73. {x: '2014-06-16', y: 30, group: 1},
  74. {x: '2014-06-17', y: 100, group: 1},
  75. {x: '2014-06-18', y: 150, group: 1},
  76. {x: '2014-06-19', y: 520, group: 1},
  77. {x: '2014-06-20', y: 100, group: 1},
  78. {x: '2014-06-21', y: 19, group: 2},
  79. {x: '2014-06-22', y: 60, group: 2},
  80. {x: '2014-06-23', y: 10, group: 2},
  81. {x: '2014-06-24', y: 25, group: 2},
  82. {x: '2014-06-25', y: 30, group: 2}
  83. // {x: '2014-06-11', y: 10},
  84. // {x: '2014-06-12', y: 25},
  85. // {x: '2014-06-13', y: 30},
  86. // {x: '2014-06-14', y: 10},
  87. // {x: '2014-06-15', y: 15},
  88. // {x: '2014-06-16', y: 30}
  89. ];
  90. var dataset = new vis.DataSet(items);
  91. var graph2d = new vis.Graph2d(container);
  92. graph2d.setOptions(options);
  93. graph2d.setGroups(groups);
  94. graph2d.setItems(dataset);
  95. </script>
  96. </body>
  97. </html>