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.

105 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. 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. // yAxisOrientation: 'right',
  60. shaded: {
  61. enabled: false,
  62. orientation: 'top' // top, bottom
  63. }
  64. }});
  65. var container = document.getElementById('visualization');
  66. var items = [
  67. {x: '2014-06-11', y: 10000 },
  68. {x: '2014-06-12', y: 25000 },
  69. {x: '2014-06-13', y: 30000, group: 0},
  70. {x: '2014-06-14', y: 10000, group: 0},
  71. {x: '2014-06-15', y: 150000, group: 1},
  72. {x: '2014-06-16', y: 300000, group: 1},
  73. {x: '2014-06-17', y: 100, group: 1},
  74. {x: '2014-06-18', y: 150, group: 1},
  75. {x: '2014-06-19', y: 520, group: 1},
  76. {x: '2014-06-20', y: 100, group: 1},
  77. {x: '2014-06-21', y: 19, group: 2},
  78. {x: '2014-06-22', y: 60, group: 2},
  79. {x: '2014-06-23', y: 10, group: 2},
  80. {x: '2014-06-24', y: 25, group: 2},
  81. {x: '2014-06-25', y: 30, group: 2}
  82. // {x: '2014-06-11', y: 10},
  83. // {x: '2014-06-12', y: 25},
  84. // {x: '2014-06-13', y: 30},
  85. // {x: '2014-06-14', y: 10},
  86. // {x: '2014-06-15', y: 15},
  87. // {x: '2014-06-16', y: 30}
  88. ];
  89. var dataset = new vis.DataSet(items);
  90. var graph2d = new vis.Graph2d(container);
  91. graph2d.setOptions(options);
  92. graph2d.setGroups(groups);
  93. graph2d.setItems(dataset);
  94. </script>
  95. </body>
  96. </html>