areaLineUpdate.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <meta name="viewport" content="width=device-width, initial-scale=1" />
  5. <script src="lib/esl.js"></script>
  6. <script src="lib/config.js"></script>
  7. <script src="lib/facePrint.js"></script>
  8. </head>
  9. <body>
  10. <style>
  11. html, body, .main {
  12. padding: 0;
  13. margin: 0;
  14. width: 100%;
  15. height: 300px;
  16. }
  17. .label {
  18. background: rgba(00, 200, 00, 0.4);
  19. padding: 10px;
  20. text-align: center;
  21. }
  22. </style>
  23. <div class="label">different category value | with ainmation | 3 times setOption</div>
  24. <div class="main" id="main0"></div>
  25. <div class="label">different category value | with ainmation | 3 times setOption | step</div>
  26. <div class="main" id="main1"></div>
  27. <div class="label">same category value | with ainmation | 2 times setOption</div>
  28. <div class="main" id="main2"></div>
  29. <!-- ==================== -->
  30. <!-- Test Case 1 -->
  31. <script>
  32. var option0 = {"tooltip":{"trigger":"axis","enterable":true,"padding":[10],"showDelay":100,"hideDelay":100,"z":0,"axisPointer":{"lineStyle":{"color":"#999"}},"textStyle":{"color":"#333"},"borderColor":"#ececec","borderWidth":1,"backgroundColor":"rgb(255,255,255)","extraCssText":"width: 200px;height: 80px;border-radius: 3px;z-index: 100;"},"grid":{"left":72,"right":77},"xAxis":{"type":"category","boundaryGap":false,"axisLine":{"show":true,"lineStyle":{"color":"#f2f2f2","width":1}},"z":0,"axisTick":false,"splitLine":{"show":false},"axisLabel":{"textStyle":{"color":"#ccc"}},"data":
  33. ["2016-07-23","2016-07-25","2016-07-26","2016-07-27","2016-07-28","2016-07-29","2016-07-30","2016-08-01","2016-08-02","2016-08-03","2016-08-05","2016-08-06","2016-08-08","2016-08-09","2016-08-10","2016-08-11","2016-08-12","2016-08-15","2016-08-16","2016-08-17","2016-08-18","2016-08-19","2016-08-20","2016-08-22"]
  34. },"yAxis":{"type":"value","z":0,"min":0,"max":100,"interval":20,"positon":"right","boundaryGap":false,"axisLine":{"show":true,"lineStyle":{"color":"#f2f2f2","width":1}},"axisTick":false,"splitLine":{"lineStyle":{"color":"#f2f2f2"}},"axisLabel":{"textStyle":{"color":"#ccc"}}},"dataZoom":[{"show":false},{"show":true,"z":0,"type":"slider","fillerColor":"rgba(230,230,230,.3)","dataBackground":{"areaStyle":{"color":"rgb(210,210,210)"}}}],"series":[{"type":"line","smooth":true,"symbol":"emptyCircle","itemStyle":{"normal":{"color":"rgb(255, 223, 190)"}},"z":0,"areaStyle":{"normal":{"color":"rgb(255, 242, 230)"}},"showAllSymbol":true,"data":
  35. ["69","65","65","64","63","69","66","67","66","66","63","62","68","66","65","70","70","71","70","58","66","68","67","62"]
  36. }]}
  37. var option1 = {"tooltip":{"trigger":"axis","enterable":true,"padding":[10],"showDelay":100,"hideDelay":100,"z":0,"axisPointer":{"lineStyle":{"color":"#999"}},"textStyle":{"color":"#333"},"borderColor":"#ececec","borderWidth":1,"backgroundColor":"rgb(255,255,255)","extraCssText":"width: 200px;height: 80px;border-radius: 3px;z-index: 100;"},"grid":{"left":72,"right":77},"xAxis":{"type":"category","boundaryGap":false,"axisLine":{"show":true,"lineStyle":{"color":"#f2f2f2","width":1}},"z":0,"axisTick":false,"splitLine":{"show":false},"axisLabel":{"textStyle":{"color":"#ccc"}},"data":
  38. ["2016-05-24","2016-05-25","2016-05-26","2016-05-27","2016-05-30","2016-06-01","2016-06-02","2016-06-03","2016-06-06","2016-06-13","2016-06-14","2016-06-15","2016-06-16","2016-06-17","2016-06-23","2016-06-24","2016-06-27","2016-06-28","2016-06-29","2016-06-30","2016-07-01","2016-07-04","2016-07-05","2016-07-06","2016-07-07","2016-07-11","2016-07-13","2016-07-14","2016-07-15","2016-07-18","2016-07-20","2016-07-21","2016-07-22","2016-07-23","2016-07-25","2016-07-26","2016-07-27","2016-07-28","2016-07-29","2016-07-30","2016-08-01","2016-08-02","2016-08-03","2016-08-05","2016-08-06","2016-08-08","2016-08-09","2016-08-10","2016-08-11","2016-08-12","2016-08-15","2016-08-16","2016-08-17","2016-08-18","2016-08-19","2016-08-20","2016-08-22"]
  39. },"yAxis":{"type":"value","z":0,"min":0,"max":100,"interval":20,"positon":"right","boundaryGap":false,"axisLine":{"show":true,"lineStyle":{"color":"#f2f2f2","width":1}},"axisTick":false,"splitLine":{"lineStyle":{"color":"#f2f2f2"}},"axisLabel":{"textStyle":{"color":"#ccc"}}},"dataZoom":[{"show":false},{"show":true,"z":0,"type":"slider","fillerColor":"rgba(230,230,230,.3)","dataBackground":{"areaStyle":{"color":"rgb(210,210,210)"}}}],"series":[{"type":"line","smooth":true,"symbol":"emptyCircle","itemStyle":{"normal":{"color":"rgb(255, 223, 190)"}},"z":0,"areaStyle":{"normal":{"color":"rgb(255, 242, 230)"}},"showAllSymbol":true,"data":
  40. ["66","66","61","59","59","57","61","63","61","65","65","65","66","70","60","62","66","66","66","70","64","66","68","69","71","67","69","71","68","69","68","69","67","69","65","65","64","63","69","66","67","66","66","63","62","68","66","65","70","70","71","70","58","66","68","67","62"]
  41. }]}
  42. var option2 = {"tooltip":{"trigger":"axis","enterable":true,"padding":[10],"showDelay":100,"hideDelay":100,"z":0,"axisPointer":{"lineStyle":{"color":"#999"}},"textStyle":{"color":"#333"},"borderColor":"#ececec","borderWidth":1,"backgroundColor":"rgb(255,255,255)","extraCssText":"width: 200px;height: 80px;border-radius: 3px;z-index: 100;"},"grid":{"left":72,"right":77},"xAxis":{"type":"category","boundaryGap":false,"axisLine":{"show":true,"lineStyle":{"color":"#f2f2f2","width":1}},"z":0,"axisTick":false,"splitLine":{"show":false},"axisLabel":{"textStyle":{"color":"#ccc"}},"data":
  43. ["2016-02-24","2016-02-25","2016-02-26","2016-02-29","2016-03-01","2016-03-02","2016-03-03","2016-03-04","2016-03-07","2016-03-08","2016-03-09","2016-03-10","2016-03-11","2016-03-15","2016-03-16","2016-03-17","2016-03-18","2016-03-21","2016-03-22","2016-03-23","2016-03-24","2016-03-25","2016-03-28","2016-03-29","2016-03-30","2016-03-31","2016-04-01","2016-04-06","2016-04-07","2016-04-08","2016-04-11","2016-04-12","2016-04-13","2016-04-14","2016-04-18","2016-04-20","2016-04-21","2016-04-22","2016-04-26","2016-04-27","2016-04-28","2016-05-05","2016-05-06","2016-05-09","2016-05-10","2016-05-12","2016-05-13","2016-05-16","2016-05-17","2016-05-19","2016-05-20","2016-05-24","2016-05-25","2016-05-26","2016-05-27","2016-05-30","2016-06-01","2016-06-02","2016-06-03","2016-06-06","2016-06-13","2016-06-14","2016-06-15","2016-06-16","2016-06-17","2016-06-23","2016-06-24","2016-06-27","2016-06-28","2016-06-29","2016-06-30","2016-07-01","2016-07-04","2016-07-05","2016-07-06","2016-07-07","2016-07-11","2016-07-13","2016-07-14","2016-07-15","2016-07-18","2016-07-20","2016-07-21","2016-07-22","2016-07-23","2016-07-25","2016-07-26","2016-07-27","2016-07-28","2016-07-29","2016-07-30","2016-08-01","2016-08-02","2016-08-03","2016-08-05","2016-08-06","2016-08-08","2016-08-09","2016-08-10","2016-08-11","2016-08-12","2016-08-15","2016-08-16","2016-08-17","2016-08-18","2016-08-19","2016-08-20","2016-08-22"]
  44. },"yAxis":{"type":"value","z":0,"min":0,"max":100,"interval":20,"positon":"right","boundaryGap":false,"axisLine":{"show":true,"lineStyle":{"color":"#f2f2f2","width":1}},"axisTick":false,"splitLine":{"lineStyle":{"color":"#f2f2f2"}},"axisLabel":{"textStyle":{"color":"#ccc"}}},"dataZoom":[{"show":false},{"show":true,"z":0,"type":"slider","fillerColor":"rgba(230,230,230,.3)","dataBackground":{"areaStyle":{"color":"rgb(210,210,210)"}}}],"series":[{"type":"line","smooth":true,"symbol":"emptyCircle","itemStyle":{"normal":{"color":"rgb(255, 223, 190)"}},"z":0,"areaStyle":{"normal":{"color":"rgb(255, 242, 230)"}},"showAllSymbol":true,"data":
  45. ["61","57","62","65","65","67","65","68","68","65","67","69","66","67","66","70","67","72","73","73","71","69","72","73","72","74","77","75","74","74","68","70","69","70","70","72","74","71","71","70","72","74","76","72","76","73","67","60","59","64","64","66","66","61","59","59","57","61","63","61","65","65","65","66","70","60","62","66","66","66","70","64","66","68","69","71","67","69","71","68","69","68","69","67","69","65","65","64","63","69","66","67","66","66","63","62","68","66","65","70","70","71","70","58","66","68","67","62"]
  46. }]}
  47. require([
  48. 'echarts'
  49. // 'echarts/chart/line',
  50. // 'echarts/component/legend',
  51. // 'echarts/component/grid',
  52. // 'echarts/component/tooltip',
  53. // 'echarts/component/dataZoom'
  54. ], function (echarts) {
  55. var main = document.getElementById('main0');
  56. if (!main) {
  57. return;
  58. }
  59. var chart = echarts.init(main);
  60. chart.setOption(option0);
  61. setTimeout(() => {
  62. chart.setOption(option1);
  63. setTimeout(() => {
  64. chart.setOption(option2);
  65. }, 2000)
  66. }, 2000)
  67. })
  68. </script>
  69. <!-- ==================== -->
  70. <!-- Test Case 2 -->
  71. <script>
  72. require([
  73. 'echarts'
  74. // 'echarts/chart/line',
  75. // 'echarts/component/legend',
  76. // 'echarts/component/grid',
  77. // 'echarts/component/tooltip',
  78. // 'echarts/component/dataZoom'
  79. ], function (echarts) {
  80. var main = document.getElementById('main1');
  81. if (!main) {
  82. return;
  83. }
  84. var chart = echarts.init(main);
  85. var option = {
  86. "grid": {
  87. "left": 72,
  88. "right": 77
  89. },
  90. "xAxis": {
  91. "type": "category",
  92. "data": ["2016-07-23","2016-08-22"]
  93. },
  94. "yAxis": {
  95. "type": "value"
  96. },
  97. "series": [
  98. {
  99. "type": "line",
  100. // step: true,
  101. "areaStyle": {
  102. "normal": {
  103. "color": "rgb(255, 242, 230)"
  104. }
  105. },
  106. step: true,
  107. stack: 'a',
  108. "showAllSymbol": true,
  109. "data": ["69","62"]
  110. },
  111. {
  112. "type": "line",
  113. step: true,
  114. "areaStyle": {
  115. "normal": {
  116. "color": "rgb(155, 242, 230)"
  117. }
  118. },
  119. stack: 'a',
  120. "showAllSymbol": true,
  121. "data": ["19","12"]
  122. }
  123. ]
  124. };
  125. var option1 = {
  126. xAxis: {data: ["2016-05-24","2016-07-23","2016-08-22"]},
  127. series: [{
  128. data: ["66","67","62"]
  129. }, {
  130. data: ["26","27","22"]
  131. }]
  132. };
  133. var option2 = {
  134. xAxis: {data: ["2016-02-24","2016-05-24","2016-07-23","2016-08-22"]},
  135. series: [
  136. {data: ["61","57","62","65"]},
  137. {data: ["31","37","32","35"]}
  138. ]
  139. };
  140. chart.setOption(option);
  141. setTimeout(function () {
  142. chart.setOption(option1);
  143. setTimeout(function () {
  144. chart.setOption(option2);
  145. }, 2000)
  146. }, 2000)
  147. });
  148. </script>
  149. <!-- ==================== -->
  150. <!-- Test Case 3 -->
  151. <script>
  152. require([
  153. 'echarts'
  154. // 'echarts/chart/line',
  155. // 'echarts/component/grid',
  156. // 'echarts/component/tooltip'
  157. ], function (echarts) {
  158. var main = document.getElementById('main2');
  159. if (!main) {
  160. return;
  161. }
  162. var chart = echarts.init(main);
  163. var xAxisData = [];
  164. var data1 = [];
  165. var data2 = [];
  166. var data3 = [];
  167. var data4 = [];
  168. xAxisData.push('类目' + -1);
  169. data1.push('-');
  170. data2.push('-');
  171. data3.push('-');
  172. data4.push('-');
  173. for (var i = 0; i < 5; i++) {
  174. xAxisData.push('类目' + i);
  175. data1.push((-Math.random() - 0.2).toFixed(3));
  176. data2.push((Math.random() + 0.3).toFixed(3));
  177. data3.push((Math.random() + 0.2).toFixed(3));
  178. data4.push((Math.random() + 0.2).toFixed(3));
  179. }
  180. xAxisData.push('类目' + i);
  181. data1.push('-');
  182. data2.push('-');
  183. data3.push('-');
  184. data4.push('-');
  185. for (; i < 10; i++) {
  186. xAxisData.push('类目' + i);
  187. data1.push((-Math.random() - 0.2).toFixed(3));
  188. data2.push((Math.random() + 0.3).toFixed(3));
  189. data3.push((Math.random() + 0.2).toFixed(3));
  190. data4.push((Math.random() + 0.2).toFixed(3));
  191. }
  192. xAxisData.push('类目' + i);
  193. data1.push('-');
  194. data2.push('-');
  195. data3.push('-');
  196. data4.push('-');
  197. var itemStyle = {
  198. normal: {
  199. // borderColor: 'white',
  200. // borderWidth: 3,
  201. // shadowBlur: 10,
  202. // shadowOffsetX: 0,
  203. // shadowOffsetY: 5,
  204. // shadowColor: 'rgba(0, 0, 0, 0.4)',
  205. lineStyle: {
  206. width: 2
  207. // shadowBlur: 10,
  208. // shadowOffsetX: 0,
  209. // shadowOffsetY: 5,
  210. // shadowColor: 'rgba(0, 0, 0, 0.4)'
  211. },
  212. areaStyle: {
  213. }
  214. }
  215. };
  216. chart.setOption({
  217. legend: {
  218. data: ['line', 'line2', 'line3']
  219. },
  220. tooltip: {
  221. trigger: 'axis',
  222. position: function (point) {
  223. return [point[0], '10%'];
  224. },
  225. axisPointer: {
  226. type: 'line'
  227. }
  228. },
  229. xAxis: {
  230. // data: ['类目1', '类目2', '类目3', '类目4', '类目5',]
  231. data: xAxisData,
  232. boundaryGap: false,
  233. // inverse: true,
  234. splitArea: {
  235. show: true
  236. }
  237. },
  238. yAxis: {
  239. },
  240. series: [{
  241. id: 'aaa',
  242. name: 'line33333',
  243. type: 'line',
  244. stack: 'all',
  245. symbolSize: 10,
  246. data: data3,
  247. itemStyle: itemStyle,
  248. label: {
  249. normal: {
  250. show: true
  251. }
  252. },
  253. connectNulls: true,
  254. smooth: true
  255. }]
  256. });
  257. setTimeout(function () {
  258. chart.setOption({
  259. series: [
  260. {
  261. id: 'aaa',
  262. name: 'xxxxxxxxxxxxxxxx',
  263. data: data4,
  264. }
  265. ]
  266. });
  267. }, 1000);
  268. })
  269. </script>
  270. </body>
  271. </html>