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.

74 lines
3.2 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 shows the workings of the subgroups. Subgroups do not use stacking, and only work when stacking is disabled.</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', subgroupOrder: function (a,b) {return a.subgroupOrder - b.subgroupOrder;}
  36. },{
  37. id: 'foo', content:'foo', subgroupOrder: 'subgroupOrder' // this group has no subgroups but this would be the other method to do the sorting.
  38. }]);
  39. // add items to the DataSet
  40. items.add([
  41. {id: 'A',start: '2014-01-20', end: '2014-01-22', type: 'background', group:'foo'},
  42. {id: 'B',start: '2014-01-22', end: '2014-01-23', type: 'background', group:'foo', className: 'negative'},
  43. {id: 0, content: 'no subgroup', start: '2014-01-20', end: '2014-01-22',group:'foo'},
  44. {id: 'SG_1_1',start: '2014-01-25', end: '2014-01-27', type: 'background', group:'bar', subgroup:'sg_1', subgroupOrder:0},
  45. {id: 'SG_1_2', start: '2014-01-26', end: '2014-01-27', type: 'background', className: 'positive',group:'bar', subgroup:'sg_1', subgroupOrder:0},
  46. {id: 1, content: 'subgroup0', start: '2014-01-23 12:00:00', end: '2014-01-26 12:00:00',group:'bar', subgroup:'sg_1', subgroupOrder:0},
  47. {id: 'SG_2_1', start: '2014-01-27', end: '2014-01-29', type: 'background', group:'bar', subgroup:'sg_2', subgroupOrder:1},
  48. {id: 'SG_2_2', start: '2014-01-27', end: '2014-01-28', type: 'background', className: 'negative',group:'bar', subgroup:'sg_2', subgroupOrder:1},
  49. {id: 2, content: 'subgroup1', start: '2014-01-27', end: '2014-01-29',group:'bar', subgroup:'sg_2', subgroupOrder:1},
  50. {id: 'background', start: '2014-01-29', end: '2014-01-30', type: 'background', className: 'negative',group:'bar'},
  51. {id: 'background_all', start: '2014-01-31', end: '2014-02-02', type: 'background', className: 'positive'},
  52. ]);
  53. var container = document.getElementById('visualization');
  54. var options = {
  55. // orientation:'top'
  56. start: '2014-01-10',
  57. end: '2014-02-10',
  58. editable: true,
  59. stack: false
  60. };
  61. var timeline = new vis.Timeline(container, items, groups, options);
  62. </script>
  63. </body>
  64. </html>