largeLine.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <script src="lib/esl.js"></script>
  5. <script src="lib/config.js"></script>
  6. <meta name="viewport" content="width=device-width, initial-scale=1" />
  7. </head>
  8. <body>
  9. <style>
  10. html, body, #main {
  11. width: 100%;
  12. height: 100%;
  13. margin: 0;
  14. }
  15. </style>
  16. <div id="timing"></div>
  17. <script>
  18. require([
  19. 'echarts'
  20. // 'echarts/chart/bar',
  21. // 'echarts/chart/line',
  22. // 'echarts/component/legend',
  23. // 'echarts/component/grid',
  24. // 'echarts/component/dataZoom',
  25. // 'echarts/component/tooltip'
  26. ], function (echarts) {
  27. var myChart;
  28. var lineCount = 20;
  29. var pointCount = 1000;
  30. var chartCount = 50;
  31. var option = {
  32. tooltip : {
  33. trigger: 'axis',
  34. axisPointer: {
  35. animation: false
  36. }
  37. },
  38. legend: {
  39. data:[]
  40. },
  41. dataZoom: [{
  42. show: true,
  43. realtime: true,
  44. // showDataShadow: false,
  45. start: 50,
  46. end: 60
  47. }],
  48. xAxis : [
  49. {
  50. type : 'time'
  51. }
  52. ],
  53. yAxis : [
  54. {
  55. type : 'value'
  56. }
  57. ],
  58. series: [],
  59. animation: false
  60. };
  61. var lineStyle = {
  62. normal: {
  63. width: 2,
  64. opacity: 1
  65. }
  66. };
  67. var date = [];
  68. var oneDay = 24 * 3600 * 1000;
  69. var base = +new Date(1897, 9, 3);
  70. for (var j = 0; j < pointCount; j++) {
  71. var now = new Date(base += oneDay);
  72. date.push([now.getFullYear(), now.getMonth() + 1, now.getDate()].join('-'));
  73. }
  74. for (var i = 0; i < lineCount; i++) {
  75. var y = Math.random() * 1000;
  76. var values = [];
  77. for (var j = 0; j < pointCount; j++) {
  78. y += Math.round(10 + Math.random() * (-10 - 10));
  79. values.push(
  80. [
  81. date[j],
  82. // Math.random() < 0.1 ? '-' : y
  83. y
  84. ]
  85. );
  86. }
  87. option.legend.data.push( 'line' + i );
  88. option.series.push({
  89. name: 'line' + i,
  90. type: 'line',
  91. sampling: 'average',
  92. hoverAnimation: false,
  93. showSymbol: false,
  94. data: values,
  95. lineStyle: lineStyle
  96. });
  97. }
  98. function refresh(isBtnRefresh){
  99. var start = new Date();
  100. for( var n = 0; n < chartCount; n++ ) {
  101. var el = document.createElement('div');
  102. el.innerHTML = '<h1>'+n+'</h1><div id="chart'+n+'" style="width: 860px; height: 320px"></div>';
  103. document.body.appendChild(el);
  104. myChart = echarts.init(document.getElementById('chart'+n));
  105. myChart.setOption(option, true);
  106. }
  107. var end = new Date();
  108. document.getElementById('timing').innerHTML = 'Graphs loaded in ' + ( end - start ) + ' ms.';
  109. };
  110. refresh();
  111. });
  112. </script>
  113. </body>
  114. </html>