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.7 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. </head>
  15. <body>
  16. <p>
  17. 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>.
  18. </p>
  19. <p>
  20. <label for="locale">Select a locale:</label>
  21. <select id="locale">
  22. <option value="en" selected>en</option>
  23. <option value="nl">nl</option>
  24. <option value="cs">cs</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. showCustomTime: true
  41. };
  42. // Create a Timeline
  43. var timeline = new vis.Timeline(container, items, options);
  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>