media-dataZoom.html 5.1 KB

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