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.

136 lines
4.4 KiB

  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>Graph2d | Both Axis Example</title>
  5. <style type="text/css">
  6. body, html {
  7. font-family: sans-serif;
  8. }
  9. .custom-style1 {
  10. fill: #f2ea00;
  11. fill-opacity:0;
  12. stroke-width:2px;
  13. stroke: #b3ab00;
  14. }
  15. .custom-style2 {
  16. fill: #00a0f2;
  17. stroke-width:2px;
  18. stroke: #050092;
  19. }
  20. .custom-style3 {
  21. fill: #00f201;
  22. fill-opacity:0;
  23. stroke-width:2px;
  24. stroke: #029200;
  25. }
  26. path.custom-style3.vis-fill {
  27. fill-opacity:0.5 !important;
  28. stroke: none;
  29. }
  30. </style>
  31. <!--IMPORTANT: import the vis css after the custom styles to avoid overriding styles-->
  32. <link href="../../dist/vis.css" rel="stylesheet" type="text/css" />
  33. <script src="../../dist/vis.js"></script>
  34. <script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', 'UA-61231638-1', 'auto');ga('send', 'pageview');</script></head>
  35. <body>
  36. <h2>Graph2d | Both Axis Example</h2>
  37. <div style="width:700px; font-size:14px; text-align: justify;">
  38. This example shows the some of the graphs outlined on the right side using the <code>yAxisOrientation</code> option within the groups.
  39. We also show a few more custom styles for the graphs. Finally, the legend is manually positioned. Both the left and right axis
  40. have their own legend. If one of the axis is unused, the legend is not shown. The options for the legend have been split
  41. in a <code>left</code> and a <code>right</code> segment. The default position of the left axis has been changed.
  42. </div>
  43. <br />
  44. <div id="visualization"></div>
  45. <script type="text/javascript">
  46. // create a dataSet with groups
  47. var names = ['SquareShaded', 'Bargraph', 'Blank', 'CircleShaded'];
  48. var groups = new vis.DataSet();
  49. groups.add({
  50. id: 0,
  51. content: names[0],
  52. className: 'custom-style1',
  53. options: {
  54. drawPoints: {
  55. style: 'square' // square, circle
  56. },
  57. shaded: {
  58. orientation: 'bottom' // top, bottom
  59. }
  60. }});
  61. groups.add({
  62. id: 1,
  63. content: names[1],
  64. className: 'custom-style2',
  65. options: {
  66. style:'bar',
  67. drawPoints: {style: 'circle',
  68. size: 10
  69. }
  70. }});
  71. groups.add({
  72. id: 2,
  73. content: names[2],
  74. options: {
  75. yAxisOrientation: 'right', // right, left
  76. drawPoints: false
  77. }
  78. });
  79. groups.add({
  80. id: 3,
  81. content: names[3],
  82. className: 'custom-style3',
  83. options: {
  84. yAxisOrientation: 'right', // right, left
  85. drawPoints: {
  86. style: 'circle' // square, circle
  87. },
  88. shaded: {
  89. orientation: 'top' // top, bottom
  90. }
  91. }});
  92. var container = document.getElementById('visualization');
  93. var items = [
  94. {x: '2014-06-12', y: 0 , group: 0},
  95. {x: '2014-06-13', y: 30, group: 0},
  96. {x: '2014-06-14', y: 10, group: 0},
  97. {x: '2014-06-15', y: 15, group: 1},
  98. {x: '2014-06-16', y: 30, group: 1},
  99. {x: '2014-06-17', y: 10, group: 1},
  100. {x: '2014-06-18', y: 15, group: 1},
  101. {x: '2014-06-19', y: 52, group: 1},
  102. {x: '2014-06-20', y: 10, group: 1},
  103. {x: '2014-06-21', y: 20, group: 2},
  104. {x: '2014-06-22', y: 600, group: 2},
  105. {x: '2014-06-23', y: 100, group: 2},
  106. {x: '2014-06-24', y: 250, group: 2},
  107. {x: '2014-06-25', y: 300, group: 2},
  108. {x: '2014-06-26', y: 200, group: 3},
  109. {x: '2014-06-27', y: 600, group: 3},
  110. {x: '2014-06-28', y: 1000, group: 3},
  111. {x: '2014-06-29', y: 250, group: 3},
  112. {x: '2014-06-30', y: 300, group: 3}
  113. ];
  114. var dataset = new vis.DataSet(items);
  115. var options = {
  116. dataAxis: {showMinorLabels: false},
  117. legend: {left:{position:"bottom-left"}},
  118. start: '2014-06-09',
  119. end: '2014-07-03'
  120. };
  121. var graph2d = new vis.Graph2d(container, dataset, groups, options);
  122. </script>
  123. </body>
  124. </html>