non-continuous.html 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <!doctype html>
  2. <head>
  3. <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
  4. <script src="http://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.2/raphael-min.js"></script>
  5. <script src="../morris.js"></script>
  6. <script src="http://cdnjs.cloudflare.com/ajax/libs/prettify/r224/prettify.min.js"></script>
  7. <script src="lib/example.js"></script>
  8. <link rel="stylesheet" href="lib/example.css">
  9. <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/prettify/r224/prettify.min.css">
  10. <link rel="stylesheet" href="../morris.css">
  11. </head>
  12. <body>
  13. <h1>Non-continuous data</h1>
  14. <p>Null series values will break the line when rendering, missing values will be skipped</p>
  15. <div id="graph"></div>
  16. <pre id="code" class="prettyprint linenums">
  17. /* data stolen from http://howmanyleft.co.uk/vehicle/jaguar_'e'_type */
  18. var day_data = [
  19. {"period": "2012-10-01", "licensed": 3407},
  20. {"period": "2012-09-30", "sorned": 0},
  21. {"period": "2012-09-29", "sorned": 618},
  22. {"period": "2012-09-20", "licensed": 3246, "sorned": 661},
  23. {"period": "2012-09-19", "licensed": 3257, "sorned": null},
  24. {"period": "2012-09-18", "licensed": 3248, "other": 1000},
  25. {"period": "2012-09-17", "sorned": 0},
  26. {"period": "2012-09-16", "sorned": 0},
  27. {"period": "2012-09-15", "licensed": 3201, "sorned": 656},
  28. {"period": "2012-09-10", "licensed": 3215}
  29. ];
  30. Morris.Line({
  31. element: 'graph',
  32. data: day_data,
  33. xkey: 'period',
  34. ykeys: ['licensed', 'sorned', 'other'],
  35. labels: ['Licensed', 'SORN', 'Other'],
  36. /* custom label formatting with `xLabelFormat` */
  37. xLabelFormat: function(d) { return (d.getMonth()+1)+'/'+d.getDate()+'/'+d.getFullYear(); },
  38. /* setting `xLabels` is recommended when using xLabelFormat */
  39. xLabels: 'day'
  40. });
  41. </pre>
  42. </body>