line.html 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. width: 100%;
  13. height: 100%;
  14. }
  15. </style>
  16. <div id="info"></div>
  17. <div id="main"></div>
  18. <script>
  19. require([
  20. 'echarts',
  21. 'theme/infographic'
  22. // 'echarts/chart/line',
  23. // 'echarts/component/title',
  24. // 'echarts/component/legend',
  25. // 'echarts/component/grid',
  26. // 'echarts/component/tooltip',
  27. // 'echarts/component/dataZoomInside',
  28. // 'zrender/svg/svg'
  29. ], function (echarts) {
  30. var chart = echarts.init(document.getElementById('main'), 'infographic', {
  31. // renderer: 'svg'
  32. });
  33. var xAxisData = [];
  34. var data1 = [];
  35. var data2 = [];
  36. var data3 = [];
  37. for (var i = 0; i < 100; i++) {
  38. if (i === 14 || i === 20) {
  39. xAxisData.push({
  40. value: '类目' + i,
  41. textStyle: {
  42. color: 'red'
  43. }
  44. });
  45. } else {
  46. xAxisData.push('类目' + i);
  47. }
  48. if (i < 5 && i > 1) {
  49. data1.push(0);
  50. }
  51. else {
  52. data1.push(+(Math.random() + 0.5).toFixed(3));
  53. }
  54. data2.push(+(Math.random() + 0.5).toFixed(3));
  55. data3.push(+(Math.random() + 0.5).toFixed(3));
  56. }
  57. var itemStyle = {
  58. normal: {
  59. borderColor: 'white',
  60. borderWidth: 3,
  61. // shadowBlur: 10,
  62. // shadowOffsetX: 0,
  63. // shadowOffsetY: 5,
  64. // shadowColor: 'rgba(0, 0, 0, 0.4)',
  65. lineStyle: {
  66. width: 1
  67. // shadowBlur: 10,
  68. // shadowOffsetX: 0,
  69. // shadowOffsetY: 5,
  70. // shadowColor: 'rgba(0, 0, 0, 0.4)'
  71. }
  72. }
  73. };
  74. chart.setOption({
  75. title: {
  76. text: '折线图{a|asdf}Step line',
  77. subtext: 'subtitle',
  78. backgroundColor: '#ee99aa',
  79. borderRadius: 5,
  80. padding: 10,
  81. textStyle: {
  82. rich: {
  83. a: {
  84. color: '#338844',
  85. fontSize: 30,
  86. borderColor: '#119955',
  87. borderWidth: 3,
  88. backgroundColor: '#445566'
  89. }
  90. }
  91. }
  92. },
  93. legend: {
  94. data: ['line', 'line2', 'line3']
  95. },
  96. visualMap: null, // 用于测试 option 中含有null的情况。
  97. tooltip: {
  98. trigger: 'axis',
  99. axisPointer: {
  100. type: 'line'
  101. }
  102. },
  103. xAxis: {
  104. // data: ['类目1', '类目2', '类目3', '类目4', '类目5',]
  105. data: xAxisData,
  106. boundaryGap: false,
  107. // inverse: true,
  108. splitArea: {
  109. show: false
  110. },
  111. splitLine: {
  112. show: false
  113. },
  114. axisLabel: {
  115. showMaxLabel: true,
  116. showMinLabel: true
  117. }
  118. },
  119. grid: {
  120. left: '10%',
  121. right: '10%'
  122. },
  123. yAxis: {
  124. splitArea: {
  125. show: true
  126. }
  127. },
  128. dataZoom: {
  129. type: 'inside',
  130. start: 10,
  131. end: 30
  132. },
  133. // animation: false,
  134. series: [null, // 用于测试 option 中含有null的情况。
  135. {
  136. name: 'line',
  137. type: 'line',
  138. stack: 'all',
  139. symbol: 'circle',
  140. symbolSize: 40,
  141. data: data1,
  142. itemStyle: itemStyle,
  143. label: {
  144. normal: {
  145. show: true,
  146. fontSize: 12
  147. }
  148. },
  149. lineStyle: {
  150. normal: {
  151. shadowBlur: 4,
  152. shadowOffsetX: 3,
  153. shadowOffsetY: 3
  154. }
  155. },
  156. step: 'end'
  157. }, {
  158. label: {
  159. normal: {
  160. show: true,
  161. position: 'outside'
  162. }
  163. },
  164. name: 'line2',
  165. type: 'line',
  166. stack: 'all',
  167. symbol: 'circle',
  168. symbolSize: 10,
  169. data: data2,
  170. itemStyle: itemStyle,
  171. step: 'end'
  172. }, {
  173. name: 'line3',
  174. type: 'line',
  175. stack: 'all',
  176. symbol: 'triangle',
  177. symbolSize: 10,
  178. data: data3,
  179. itemStyle: itemStyle,
  180. step: 'end'
  181. }]
  182. });
  183. window.onresize = chart.resize;
  184. })
  185. </script>
  186. </body>
  187. </html>