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.

66 lines
1.8 KiB

  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>Timeline | Dynamic Content</title>
  5. <script src="../../../dist/vis.js"></script>
  6. <link href="../../../dist/vis.min.css" rel="stylesheet" type="text/css" />
  7. <style type="text/css">
  8. .progress-wrapper {
  9. background: white;
  10. width: 100%;
  11. height: 18px;
  12. text-align: center;
  13. position: relative;
  14. overflow: hidden;
  15. }
  16. .progress {
  17. height: 100%;
  18. width: 60%;
  19. position: absolute;
  20. left: 0px;
  21. top: 0px;
  22. background: #63ed63;
  23. }
  24. .progress-label {
  25. position: absolute;
  26. z-index: 1;
  27. }
  28. </style>
  29. </head>
  30. <body>
  31. <div id="myTimeline"></div>
  32. <script type="text/javascript">
  33. // DOM element where the Timeline will be attached
  34. var container = document.getElementById('myTimeline');
  35. // Create a DataSet (allows two way data-binding)
  36. var items = new vis.DataSet([
  37. {id: 1, value: 0.2, content: 'item 1', start: '2014-04-20', end: '2014-04-26'},
  38. {id: 2, value: 0.6, content: 'item 2', start: '2014-05-14', end: '2014-05-18'},
  39. {id: 3, type: 'point', content: 'item 3', start: '2014-04-15', end: '2014-05-18'},
  40. {id: 4, content: 'item 4 with visibleFramTemplate in item', start: '2014-04-16', end: '2014-04-26', visibleFramTemplate: '<div class="progress-wrapper"><div class="progress"></div><label class="progress-label">80%<label></div>'
  41. }
  42. ]);
  43. // Configuration for the Timeline
  44. var options = {
  45. visibleFrameTemplate: function(item) {
  46. if (item.visibleFramTemplate) {
  47. return item.visibleFramTemplate;
  48. }
  49. var percentage = item.value * 100 + '%';
  50. return '<div class="progress-wrapper"><div class="progress"></div><label class="progress-label">' + percentage + '<label></div>';
  51. }
  52. };
  53. // Create a Timeline
  54. var timeline = new vis.Timeline(container, items, options);
  55. </script>
  56. </body>
  57. </html>