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.

72 lines
2.8 KiB

  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>Timeline | Background areas</title>
  5. <style>
  6. body, html {
  7. font-family: arial, sans-serif;
  8. font-size: 11pt;
  9. }
  10. .vis.timeline .item.background.negative {
  11. background-color: rgba(255, 0, 0, 0.2);
  12. }
  13. .vis.timeline .item.background.positive {
  14. background-color: rgba(105, 255, 98, 0.20);
  15. }
  16. .vis.timeline .item.background.marker {
  17. border-left: 2px solid green;
  18. }
  19. </style>
  20. <script src="../../dist/vis.js"></script>
  21. <link href="../../dist/vis.css" rel="stylesheet" type="text/css" />
  22. </head>
  23. <body>
  24. <p>This example demonstrates the item type "background", see "Period A" and "Period B". The background areas can be styled with css.</p>
  25. <div id="visualization"></div>
  26. <script>
  27. // create a dataset with items
  28. // we specify the type of the fields `start` and `end` here to be strings
  29. // containing an ISO date. The fields will be outputted as ISO dates
  30. // automatically getting data from the DataSet via items.get().
  31. var items = new vis.DataSet({
  32. type: { start: 'ISODate', end: 'ISODate' }
  33. });
  34. var groups = new vis.DataSet([{
  35. id: 'bar', content:'bar'
  36. },{
  37. id: 'foo', content:'foo'
  38. }]);
  39. // add items to the DataSet
  40. items.add([
  41. {id: 'A', content:'1',start: '2014-01-20', end: '2014-01-22', type: 'background', group:'foo'},
  42. {id: 'B', content:'1',start: '2014-01-22', end: '2014-01-23', type: 'background', group:'foo', className: 'negative'},
  43. {id: 0, content: 'item 4', start: '2014-01-20', end: '2014-01-22',group:'foo'},
  44. {id: 'ab', content:'1',start: '2014-01-25', end: '2014-01-27', type: 'background', group:'bar', subgroup:'banana'},
  45. {id: 'bb', content:'1',start: '2014-01-26', end: '2014-01-27', type: 'background', className: 'positive',group:'bar', subgroup:'banana'},
  46. {id: 1, content: '0', start: '2014-01-25 12:00:00', end: '2014-01-26 12:00:00',group:'bar', subgroup:'banana'},
  47. {id: 'aab', content:'1',start: '2014-01-27', end: '2014-01-29', type: 'background', group:'bar', subgroup:'putty'},
  48. {id: 'bab', content:'1',start: '2014-01-27', end: '2014-01-28', type: 'background', className: 'negative',group:'bar', subgroup:'putty'},
  49. {id: 'bdab', content:'1',start: '2014-01-29', end: '2014-01-30', type: 'background', className: 'negative',group:'bar'},
  50. {id: 2, content: 'subgroup1', start: '2014-01-27', end: '2014-01-29',group:'bar', subgroup:'putty'},
  51. ]);
  52. var container = document.getElementById('visualization');
  53. var options = {
  54. start: '2014-01-10',
  55. end: '2014-02-10',
  56. editable: true,
  57. stack: false,
  58. // orientation:'top'
  59. };
  60. var timeline = new vis.Timeline(container, items, groups, options);
  61. </script>
  62. </body>
  63. </html>