media-dataZoom.html 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <script src="esl.js"></script>
  5. <script src="config.js"></script>
  6. <script src="lib/jquery.min.js"></script>
  7. <script src="lib/draggable.js"></script>
  8. <link rel="stylesheet" href="reset.css">
  9. <meta name="viewport" content="width=device-width, initial-scale=1" />
  10. </head>
  11. <body>
  12. <style>
  13. body {
  14. position: absolute;
  15. left: 0;
  16. top: 0;
  17. }
  18. #main {
  19. position: absolute;
  20. top: 10px;
  21. left: 10px;
  22. width: 700px;
  23. height: 650px;
  24. background: #fff;
  25. }
  26. </style>
  27. <div id="main"></div>
  28. <script src="data/timelineGDP.js"></script>
  29. <script>
  30. require([
  31. 'echarts',
  32. 'echarts/chart/scatter',
  33. 'echarts/component/title',
  34. 'echarts/component/legend',
  35. 'echarts/component/tooltip',
  36. 'echarts/component/dataZoom'
  37. ], function (echarts) {
  38. chart = echarts.init(document.getElementById('main'), null, {
  39. renderer: 'canvas'
  40. });
  41. draggable.init(
  42. document.getElementById('main'),
  43. chart,
  44. {throttle: 70}
  45. );
  46. var data1 = [];
  47. var random = function (max) {
  48. return (Math.random() * max).toFixed(3);
  49. };
  50. for (var i = 0; i < 100; i++) {
  51. data1.push([random(15), random(10), random(1)]);
  52. }
  53. option = {
  54. baseOption: {
  55. animation: false,
  56. legend: {
  57. data: ['scatter', 'scatter2', 'scatter3']
  58. },
  59. toolbox: {
  60. // y: 'bottom',
  61. feature: {
  62. dataView: {},
  63. dataZoom: {show: true},
  64. restore: {show: true},
  65. saveAsImage: {}
  66. }
  67. },
  68. tooltip: {
  69. },
  70. xAxis: {
  71. type: 'value',
  72. min: 'dataMin',
  73. max: 'dataMax',
  74. splitLine: {
  75. show: true
  76. }
  77. },
  78. yAxis: {
  79. type: 'value',
  80. min: 'dataMin',
  81. max: 'dataMax',
  82. splitLine: {
  83. show: true
  84. }
  85. },
  86. dataZoom: [
  87. {
  88. id: 'sliderX',
  89. show: true,
  90. xAxisIndex: [0],
  91. start: 10,
  92. end: 70
  93. },
  94. {
  95. id: 'sliderY',
  96. show: true,
  97. yAxisIndex: [0],
  98. start: 0,
  99. end: 20
  100. },
  101. {
  102. type: 'inside',
  103. xAxisIndex: [0],
  104. start: 10,
  105. end: 70
  106. },
  107. {
  108. type: 'inside',
  109. yAxisIndex: [0],
  110. start: 0,
  111. end: 20
  112. }
  113. ],
  114. series: [
  115. {
  116. name: 'scatter',
  117. type: 'scatter',
  118. itemStyle: {
  119. normal: {
  120. opacity: 0.8
  121. // shadowBlur: 10,
  122. // shadowOffsetX: 0,
  123. // shadowOffsetY: 0,
  124. // shadowColor: 'rgba(0, 0, 0, 0.5)'
  125. }
  126. },
  127. symbolSize: function (val) {
  128. return val[2] * 40;
  129. },
  130. data: data1
  131. }
  132. ]
  133. },
  134. media: [
  135. {
  136. query: {maxWidth: 450},
  137. option: {
  138. dataZoom: [
  139. {id: 'sliderY', width: 10}
  140. ]
  141. }
  142. },
  143. {
  144. query: {minWidth: 450},
  145. option: {
  146. dataZoom: [
  147. {id: 'sliderY', width: 40}
  148. ]
  149. }
  150. },
  151. {
  152. query: {maxHeight: 450},
  153. option: {
  154. dataZoom: [
  155. {id: 'sliderX', height: 10}
  156. ]
  157. }
  158. },
  159. {
  160. query: {minHeight: 450},
  161. option: {
  162. dataZoom: [
  163. {id: 'sliderX', height: 40}
  164. ]
  165. }
  166. }
  167. ]
  168. };
  169. chart.setOption(option);
  170. chart.on('legendSelected', function () {
  171. });
  172. window.onresize = chart.resize;
  173. });
  174. </script>
  175. </body>
  176. </html>