dataZoom-scatter-toolbox.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. margin: 0;
  12. padding: 0;
  13. width: 100%;
  14. height: 100%;
  15. }
  16. </style>
  17. <div id="main"></div>
  18. <script>
  19. require([
  20. 'echarts',
  21. 'echarts/chart/scatter',
  22. 'echarts/component/legend',
  23. 'echarts/component/grid',
  24. 'echarts/component/tooltip',
  25. 'echarts/component/toolbox',
  26. 'echarts/component/dataZoom'
  27. ], function (echarts) {
  28. chart = echarts.init(document.getElementById('main'), null, {
  29. renderer: 'canvas'
  30. });
  31. var data1 = [];
  32. var data2 = [];
  33. var data3 = [];
  34. var random = function (max) {
  35. return (Math.random() * max).toFixed(3);
  36. };
  37. for (var i = 0; i < 100; i++) {
  38. data1.push([random(15), random(10), random(1)]);
  39. // data1.push([i, 10, i]);
  40. data2.push([random(10), random(10), random(1)]);
  41. data3.push([random(15), random(10), random(1)]);
  42. }
  43. // console.profile('setOption');
  44. chart.setOption({
  45. animation: false,
  46. legend: {
  47. data: ['scatter', 'scatter2', 'scatter3']
  48. },
  49. toolbox: {
  50. // y: 'bottom',
  51. feature: {
  52. dataView: {},
  53. dataZoom: {show: true},
  54. restore: {show: true},
  55. saveAsImage: {}
  56. }
  57. },
  58. tooltip: {
  59. },
  60. xAxis: {
  61. type: 'value',
  62. min: 'dataMin',
  63. max: 'dataMax',
  64. splitLine: {
  65. show: true
  66. }
  67. },
  68. yAxis: {
  69. type: 'value',
  70. min: 'dataMin',
  71. max: 'dataMax',
  72. splitLine: {
  73. show: true
  74. }
  75. },
  76. dataZoom: [
  77. {
  78. show: true,
  79. xAxisIndex: [0],
  80. start: 10,
  81. end: 70
  82. },
  83. {
  84. show: true,
  85. yAxisIndex: [0],
  86. start: 0,
  87. end: 20
  88. },
  89. {
  90. type: 'inside',
  91. xAxisIndex: [0],
  92. start: 10,
  93. end: 70
  94. },
  95. {
  96. type: 'inside',
  97. yAxisIndex: [0],
  98. start: 0,
  99. end: 20
  100. }
  101. ],
  102. series: [
  103. {
  104. name: 'scatter',
  105. type: 'scatter',
  106. itemStyle: {
  107. normal: {
  108. opacity: 0.8,
  109. // shadowBlur: 10,
  110. // shadowOffsetX: 0,
  111. // shadowOffsetY: 0,
  112. // shadowColor: 'rgba(0, 0, 0, 0.5)'
  113. }
  114. },
  115. symbolSize: function (val) {
  116. return val[2] * 40;
  117. },
  118. data: data1
  119. },
  120. {
  121. name: 'scatter2',
  122. type: 'scatter',
  123. itemStyle: {
  124. normal: {
  125. opacity: 0.8
  126. }
  127. },
  128. symbolSize: function (val) {
  129. return val[2] * 40;
  130. },
  131. data: data2
  132. },
  133. {
  134. name: 'scatter3',
  135. type: 'scatter',
  136. itemStyle: {
  137. normal: {
  138. opacity: 0.8,
  139. }
  140. },
  141. symbolSize: function (val) {
  142. return val[2] * 40;
  143. },
  144. data: data3
  145. }
  146. ]
  147. });
  148. // console.profileEnd('setOption');
  149. })
  150. window.onresize = function () {
  151. chart.resize();
  152. };
  153. </script>
  154. <!-- // <script src="js/memory-stats.js"></script> -->
  155. <!-- // <script src="js/memory.js"></script> -->
  156. </body>
  157. </html>