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.

138 lines
4.0 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.
  40. Finally, the legend is manually positioned. Both the left and right axis
  41. have their own legend. If one of the axis is unused, the legend is not shown. The options for the legend have been split
  42. in a <code>left</code> and a <code>right</code> segment. Since this example shows the right axis, the right legend is configured.
  43. </div>
  44. <br />
  45. <div id="visualization"></div>
  46. <script type="text/javascript">
  47. // create a dataSet with groups
  48. var names = ['SquareShaded', 'Bar', 'Blank', 'CircleShaded'];
  49. var groups = new vis.DataSet();
  50. groups.add({
  51. id: 0,
  52. content: names[0],
  53. className: 'customStyle1',
  54. options: {
  55. drawPoints: {
  56. style: 'square' // square, circle
  57. },
  58. shaded: {
  59. orientation: 'bottom' // top, bottom
  60. }
  61. }});
  62. groups.add({
  63. id: 1,
  64. content: names[1],
  65. className: 'customStyle2',
  66. options: {
  67. style:'bar',
  68. drawPoints: {style: 'circle',
  69. size: 10
  70. }
  71. }});
  72. groups.add({
  73. id: 2,
  74. content: names[2],
  75. options: {
  76. yAxisOrientation: 'right', // right, left
  77. drawPoints: false
  78. }
  79. });
  80. groups.add({
  81. id: 3,
  82. content: names[3],
  83. className: 'customStyle3',
  84. options: {
  85. yAxisOrientation: 'right', // right, left
  86. drawPoints: {
  87. style: 'circle' // square, circle
  88. },
  89. shaded: {
  90. orientation: 'top' // top, bottom
  91. }
  92. }});
  93. var container = document.getElementById('visualization');
  94. var items = [
  95. {x: '2014-06-12', y: 0 , group: 0},
  96. {x: '2014-06-13', y: 30, group: 0},
  97. {x: '2014-06-14', y: 10, group: 0},
  98. {x: '2014-06-15', y: 15, group: 1},
  99. {x: '2014-06-16', y: 30, group: 1},
  100. {x: '2014-06-17', y: 10, group: 1},
  101. {x: '2014-06-18', y: 15, group: 1},
  102. {x: '2014-06-19', y: 52, group: 1},
  103. {x: '2014-06-20', y: 10, group: 1},
  104. {x: '2014-06-21', y: 20, group: 2},
  105. {x: '2014-06-22', y: 600, group: 2},
  106. {x: '2014-06-23', y: 100, group: 2},
  107. {x: '2014-06-24', y: 250, group: 2},
  108. {x: '2014-06-25', y: 300, group: 2},
  109. {x: '2014-06-26', y: 200, group: 3},
  110. {x: '2014-06-27', y: 600, group: 3},
  111. {x: '2014-06-28', y: 1000, group: 3},
  112. {x: '2014-06-29', y: 250, group: 3},
  113. {x: '2014-06-30', y: 300, group: 3}
  114. ];
  115. var dataset = new vis.DataSet(items);
  116. var options = {
  117. dataAxis: {showMinorLabels: false},
  118. legend: {left:{position:"bottom-left"},right:{position:'top-right'}},
  119. start: '2014-06-09',
  120. end: '2014-07-03'
  121. };
  122. var graph2d = new vis.Graph2d(container, items, options, groups);
  123. </script>
  124. </body>
  125. </html>