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.

56 lines
1.7 KiB

  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>Graph2d | Bar Graph Example</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. <h2>Graph2D | Bar Graph Example</h2>
  15. <div style="width:700px; font-size:14px; text-align: justify;">
  16. This example shows the most the same data as the first example, except we plot the data as bars! The
  17. dataAxis (y-axis) icons have been enabled as well. These icons are generated automatically from the CSS
  18. styling of the graphs. Finally, we've used the option from Timeline where we draw the x-axis (time-axis) on top.
  19. <br /><br />
  20. The <code>align</code> option can be used to align the bar at the center of the datapoint or on the left or right side of it.
  21. This example uses the default center alignment.
  22. </div>
  23. <br />
  24. <div id="visualization"></div>
  25. <script type="text/javascript">
  26. var container = document.getElementById('visualization');
  27. var items = [
  28. {x: '2014-06-11', y: 10},
  29. {x: '2014-06-12', y: 25},
  30. {x: '2014-06-13', y: 30},
  31. {x: '2014-06-14', y: 10},
  32. {x: '2014-06-15', y: 15},
  33. {x: '2014-06-16', y: 30}
  34. ];
  35. var dataset = new vis.DataSet(items);
  36. var options = {
  37. style:'bar',
  38. barChart: {width:50, align:'center'}, // align: left, center, right
  39. drawPoints: false,
  40. dataAxis: {
  41. icons:true
  42. },
  43. orientation:'top',
  44. start: '2014-06-10',
  45. end: '2014-06-18'
  46. };
  47. var graph2d = new vis.Graph2d(container, items, options);
  48. </script>
  49. </body>
  50. </html>