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.

65 lines
1.8 KiB

  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>Timeline | Localization</title>
  5. <style type="text/css">
  6. body, html, select {
  7. font-family: sans-serif;
  8. font-size: 11pt;
  9. }
  10. </style>
  11. <script src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.1/moment-with-locales.min.js"></script>
  12. <script src="../../../dist/vis.js"></script>
  13. <link href="../../../dist/vis.css" rel="stylesheet" type="text/css" />
  14. <script src="../../googleAnalytics.js"></script>
  15. </head>
  16. <body>
  17. <p>
  18. To localize the Timeline, one has to load a version of moment.js including locales. To set a locale, specify option <code>{locale: STRING}</code>.
  19. </p>
  20. <p>
  21. <label for="locale">Select a locale:</label>
  22. <select id="locale">
  23. <option value="en" selected>en</option>
  24. <option value="nl">nl</option>
  25. </select>
  26. </p>
  27. <div id="visualization"></div>
  28. <script type="text/javascript">
  29. var DAY = 24 * 60 * 60 * 1000;
  30. // DOM element where the Timeline will be attached
  31. var container = document.getElementById('visualization');
  32. // Create a DataSet (allows two way data-binding)
  33. var items = new vis.DataSet([
  34. {id: 1, content: 'item 1', start: new Date(new Date().valueOf() - DAY)},
  35. {id: 2, content: 'item 2', start: new Date(new Date().valueOf() + 2 * DAY)}
  36. ]);
  37. // Configuration for the Timeline
  38. var options = {
  39. showCurrentTime: true
  40. };
  41. // Create a Timeline
  42. var timeline = new vis.Timeline(container, items, options);
  43. timeline.addCustomTime(new Date());
  44. timeline.setCustomTime(new Date(new Date().valueOf() + DAY));
  45. // update the locale when changing the select box value
  46. var select = document.getElementById('locale');
  47. select.onchange = function () {
  48. timeline.setOptions({
  49. locale: this.value
  50. });
  51. };
  52. select.onchange();
  53. </script>
  54. </body>
  55. </html>