largeLine.html 4.1 KB

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