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.

137 lines
3.9 KiB

  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>Graph2d | Both Axis Example</title>
  5. <link href="../../dist/vis.css" rel="stylesheet" type="text/css" />
  6. <style type="text/css">
  7. body, html {
  8. font-family: sans-serif;
  9. }
  10. .customStyle1 {
  11. fill: #f2ea00;
  12. fill-opacity:0;
  13. stroke-width:2px;
  14. stroke: #b3ab00;
  15. }
  16. .customStyle2 {
  17. fill: #00a0f2;
  18. fill-opacity:0;
  19. stroke-width:2px;
  20. stroke: #050092;
  21. }
  22. .customStyle3 {
  23. fill: #00f201;
  24. fill-opacity:0;
  25. stroke-width:2px;
  26. stroke: #029200;
  27. }
  28. path.customStyle3.fill {
  29. fill-opacity:0.5 !important;
  30. stroke: none;
  31. }
  32. </style>
  33. <script src="../../dist/vis.js"></script>
  34. </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: 'customStyle1',
  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: 'customStyle2',
  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: 'customStyle3',
  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, items, groups, options);
  122. </script>
  123. </body>
  124. </html>