largeLine-tooltip.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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="main"></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 = 1;
  29. var pointCount = 60 * 10000;
  30. var chart = echarts.init(document.getElementById('main'));
  31. var option = {
  32. tooltip : {
  33. trigger: 'axis',
  34. // showContent: false,
  35. axisPointer: {
  36. type: 'cross'
  37. // animation: false
  38. }
  39. },
  40. legend: {
  41. data:[]
  42. },
  43. // dataZoom: [{
  44. // show: true,
  45. // realtime: true,
  46. // // showDataShadow: false,
  47. // start: 50,
  48. // end: 60
  49. // }],
  50. xAxis : [
  51. {
  52. type : 'time'
  53. }
  54. ],
  55. yAxis : [
  56. {
  57. type : 'value'
  58. }
  59. ],
  60. series: [],
  61. animation: false
  62. };
  63. var lineStyle = {
  64. normal: {
  65. width: 2,
  66. opacity: 1
  67. }
  68. };
  69. var date = [];
  70. var oneDay = 24 * 3600 * 1000;
  71. var base = +new Date(1897, 9, 3);
  72. for (var j = 0; j < pointCount; j++) {
  73. var now = new Date(base += oneDay);
  74. date.push([now.getFullYear(), now.getMonth() + 1, now.getDate()].join('-'));
  75. }
  76. for (var i = 0; i < lineCount; i++) {
  77. var y = Math.random() * 1000;
  78. var values = [];
  79. for (var j = 0; j < pointCount; j++) {
  80. y += Math.round(10 + Math.random() * (-10 - 10));
  81. values.push(
  82. [
  83. date[j],
  84. // Math.random() < 0.1 ? '-' : y
  85. y
  86. ]
  87. );
  88. }
  89. option.legend.data.push( 'line' + i );
  90. option.series.push({
  91. name: 'line' + i,
  92. type: 'line',
  93. sampling: 'average',
  94. showAllSymbol: true,
  95. symbol: 'emptyCircle',
  96. // symbolSize: 0.1,
  97. hoverAnimation: false,
  98. // showSymbol: false,
  99. data: values,
  100. lineStyle: lineStyle
  101. });
  102. }
  103. chart.setOption(option);
  104. });
  105. </script>
  106. </body>
  107. </html>