dataZoom-scatter-category.html 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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 xAxisData = [];
  35. var yAxisData = [];
  36. var random = function (max) {
  37. return (Math.random() * max).toFixed(3);
  38. };
  39. for (var i = 0; i <= 10; i++) {
  40. xAxisData.push(i + '');
  41. }
  42. for (var i = 0; i <= 30; i++) {
  43. yAxisData.push(i + '');
  44. }
  45. for (var i = 0; i < 30; i++) {
  46. data1.push([
  47. Math.round(random(10)),
  48. Math.round(random(30))//,
  49. // Math.round(random(100))
  50. ]);
  51. data2.push([
  52. Math.round(random(10)),
  53. Math.round(random(30))//,
  54. // Math.round(random(100))
  55. ]);
  56. data3.push([
  57. Math.round(random(10)),
  58. Math.round(random(30))//,
  59. // Math.round(random(100))
  60. ]);
  61. }
  62. chart.setOption({
  63. legend: {
  64. data: ['scatter', 'scatter2', 'scatter3']
  65. },
  66. toolbox: {
  67. // y: 'bottom',
  68. feature: {
  69. dataView: {},
  70. dataZoom: {
  71. show: true
  72. // yAxisIndex: false
  73. },
  74. restore: {show: true},
  75. saveAsImage: {}
  76. }
  77. },
  78. tooltip: {
  79. },
  80. dataZoom: [
  81. {
  82. show: true,
  83. xAxisIndex: [0],
  84. // If set to 'filter', y axis will be effected by x dataZoom
  85. filterMode: 'empty',
  86. start: 0,
  87. end: 100
  88. },
  89. {
  90. show: true,
  91. yAxisIndex: [0],
  92. filterMode: 'empty',
  93. start: 0,
  94. end: 20
  95. },
  96. {
  97. type: 'inside',
  98. xAxisIndex: [0],
  99. filterMode: 'empty',
  100. start: 0,
  101. end: 100
  102. },
  103. {
  104. type: 'inside',
  105. yAxisIndex: [0],
  106. filterMode: 'empty',
  107. start: 0,
  108. end: 20
  109. }
  110. ],
  111. xAxis: {
  112. type: 'category',
  113. splitLine: {
  114. show: true
  115. },
  116. data: xAxisData
  117. },
  118. yAxis: {
  119. type: 'category',
  120. splitLine: {
  121. show: true
  122. },
  123. data: yAxisData
  124. },
  125. series: [
  126. {
  127. name: 'scatter',
  128. type: 'scatter',
  129. itemStyle: {
  130. normal: {
  131. opacity: 0.8,
  132. // shadowBlur: 10,
  133. // shadowOffsetX: 0,
  134. // shadowOffsetY: 0,
  135. // shadowColor: 'rgba(0, 0, 0, 0.5)'
  136. }
  137. },
  138. symbolSize: function (val) {
  139. return val[0] * 4;
  140. },
  141. data: data1
  142. },
  143. {
  144. name: 'scatter2',
  145. type: 'scatter',
  146. itemStyle: {
  147. normal: {
  148. opacity: 0.8
  149. }
  150. },
  151. symbolSize: function (val) {
  152. return val[0] * 4;
  153. },
  154. data: data2
  155. },
  156. {
  157. name: 'scatter3',
  158. type: 'scatter',
  159. itemStyle: {
  160. normal: {
  161. opacity: 0.8,
  162. }
  163. },
  164. symbolSize: function (val) {
  165. return val[0] * 4;
  166. },
  167. data: data3
  168. }
  169. ]
  170. });
  171. // console.profileEnd('setOption');
  172. })
  173. window.onresize = function () {
  174. chart.resize();
  175. };
  176. </script>
  177. <!-- // <script src="js/memory-stats.js"></script> -->
  178. <!-- // <script src="js/memory.js"></script> -->
  179. </body>
  180. </html>