index.htm 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title>Highcharts Example</title>
  7. <style type="text/css">
  8. </style>
  9. </head>
  10. <body>
  11. <script src="../../code/highcharts.js"></script>
  12. <script src="../../code/modules/boost.js"></script>
  13. <script src="../../code/modules/exporting.js"></script>
  14. <div id="container" style="height: 400px; max-width: 800px; margin: 0 auto"></div>
  15. <script type="text/javascript">
  16. function getData(n) {
  17. var arr = [],
  18. i,
  19. x,
  20. a,
  21. b,
  22. c,
  23. spike;
  24. for (
  25. i = 0, x = Date.UTC(new Date().getUTCFullYear(), 0, 1) - n * 36e5;
  26. i < n;
  27. i = i + 1, x = x + 36e5
  28. ) {
  29. if (i % 100 === 0) {
  30. a = 2 * Math.random();
  31. }
  32. if (i % 1000 === 0) {
  33. b = 2 * Math.random();
  34. }
  35. if (i % 10000 === 0) {
  36. c = 2 * Math.random();
  37. }
  38. if (i % 50000 === 0) {
  39. spike = 10;
  40. } else {
  41. spike = 0;
  42. }
  43. arr.push([
  44. x,
  45. 2 * Math.sin(i / 100) + a + b + c + spike + Math.random()
  46. ]);
  47. }
  48. return arr;
  49. }
  50. var n = 500000,
  51. data = getData(n);
  52. console.time('line');
  53. Highcharts.chart('container', {
  54. chart: {
  55. zoomType: 'x'
  56. },
  57. title: {
  58. text: 'Highcharts drawing ' + n + ' points'
  59. },
  60. subtitle: {
  61. text: 'Using the Boost module'
  62. },
  63. tooltip: {
  64. valueDecimals: 2
  65. },
  66. xAxis: {
  67. type: 'datetime'
  68. },
  69. series: [{
  70. data: data,
  71. lineWidth: 0.5,
  72. name: 'Hourly data points'
  73. }]
  74. });
  75. console.timeEnd('line');
  76. </script>
  77. </body>
  78. </html>