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.6 KiB

  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
  5. <meta content="utf-8" http-equiv="encoding">
  6. <title>Graph2d | Localization</title>
  7. <style type="text/css">
  8. body, html, select {
  9. font-family: sans-serif;
  10. font-size: 11pt;
  11. }
  12. </style>
  13. <script src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.1/moment-with-locales.min.js"></script>
  14. <script src="../../dist/vis.js"></script>
  15. <link href="../../dist/vis.css" rel="stylesheet" type="text/css" />
  16. </head>
  17. <body>
  18. <h2>Graph2d | Localization</h2>
  19. <p>
  20. To localize Graph2d, one has to load a version of moment.js including locales. To set a locale, specify option <code>{locale: STRING}</code>.
  21. </p>
  22. <p>
  23. <label for="locale">Select a locale:</label>
  24. <select id="locale">
  25. <option value="en" selected>en</option>
  26. <option value="nl">nl</option>
  27. <option value="cs">cs</option>
  28. </select>
  29. </p>
  30. <div id="visualization"></div>
  31. <script type="text/javascript">
  32. var container = document.getElementById('visualization');
  33. var items = [
  34. {x: '2014-06-11', y: 10},
  35. {x: '2014-06-12', y: 25},
  36. {x: '2014-06-13', y: 30},
  37. {x: '2014-06-14', y: 10},
  38. {x: '2014-06-15', y: 15},
  39. {x: '2014-06-16', y: 30}
  40. ];
  41. var dataset = new vis.DataSet(items);
  42. var options = {
  43. start: '2014-06-10',
  44. end: '2014-06-18'
  45. };
  46. var graph2d = new vis.Graph2d(container, dataset, options);
  47. // update the locale when changing the select box value
  48. var select = document.getElementById('locale');
  49. select.onchange = function () {
  50. graph2d.setOptions({
  51. locale: this.value
  52. });
  53. };
  54. select.onchange();
  55. </script>
  56. </body>
  57. </html>