dataZoom-scatter-toolbox.html 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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: {
  54. show: true,
  55. yAxisIndex: null
  56. },
  57. restore: {show: true},
  58. saveAsImage: {}
  59. }
  60. },
  61. tooltip: {
  62. },
  63. xAxis: {
  64. type: 'value',
  65. min: 'dataMin',
  66. max: 'dataMax',
  67. splitLine: {
  68. show: true
  69. }
  70. },
  71. yAxis: {
  72. type: 'value',
  73. min: 'dataMin',
  74. max: 'dataMax',
  75. splitLine: {
  76. show: true
  77. }
  78. },
  79. dataZoom: [
  80. {
  81. show: true,
  82. xAxisIndex: [0],
  83. start: 10,
  84. end: 70
  85. },
  86. {
  87. show: true,
  88. yAxisIndex: [0],
  89. start: 0,
  90. end: 20
  91. },
  92. {
  93. type: 'inside',
  94. xAxisIndex: [0],
  95. start: 10,
  96. end: 70
  97. },
  98. {
  99. type: 'inside',
  100. yAxisIndex: [0],
  101. start: 0,
  102. end: 20
  103. }
  104. ],
  105. series: [
  106. {
  107. name: 'scatter',
  108. type: 'scatter',
  109. itemStyle: {
  110. normal: {
  111. opacity: 0.8,
  112. // shadowBlur: 10,
  113. // shadowOffsetX: 0,
  114. // shadowOffsetY: 0,
  115. // shadowColor: 'rgba(0, 0, 0, 0.5)'
  116. }
  117. },
  118. symbolSize: function (val) {
  119. return val[2] * 40;
  120. },
  121. data: data1
  122. },
  123. {
  124. name: 'scatter2',
  125. type: 'scatter',
  126. itemStyle: {
  127. normal: {
  128. opacity: 0.8
  129. }
  130. },
  131. symbolSize: function (val) {
  132. return val[2] * 40;
  133. },
  134. data: data2
  135. },
  136. {
  137. name: 'scatter3',
  138. type: 'scatter',
  139. itemStyle: {
  140. normal: {
  141. opacity: 0.8,
  142. }
  143. },
  144. symbolSize: function (val) {
  145. return val[2] * 40;
  146. },
  147. data: data3
  148. }
  149. ]
  150. });
  151. chart.on('dataZoom', function (params) {
  152. console.log(chart.getOption().dataZoom);
  153. });
  154. // console.profileEnd('setOption');
  155. })
  156. window.onresize = function () {
  157. chart.resize();
  158. };
  159. </script>
  160. <!-- // <script src="js/memory-stats.js"></script> -->
  161. <!-- // <script src="js/memory.js"></script> -->
  162. </body>
  163. </html>