line1.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. layui.use(['echarts'], function() {
  2. let echarts = layui.echarts;
  3. var line2 = echarts.init(document.getElementById('line2'),null, {
  4. width: 600,
  5. height: 400
  6. });
  7. const colorList = ["#9E87FF", '#73DDFF', '#fe9a8b', '#F56948', '#9E87FF']
  8. option = {
  9. backgroundColor: '#fff',
  10. title: {
  11. text: '全国6月销售统计',
  12. fontSize: 12,
  13. fontWeight: 400,
  14. left: 'center',
  15. top: '5%'
  16. },
  17. legend: {
  18. icon: 'circle',
  19. top: '5%',
  20. right: '5%',
  21. itemWidth: 6,
  22. itemGap: 20,
  23. color: '#556677'
  24. },
  25. tooltip: {
  26. trigger: 'axis',
  27. axisPointer: {
  28. label: {
  29. show: true,
  30. backgroundColor: '#fff',
  31. color: '#556677',
  32. borderColor: 'rgba(0,0,0,0)',
  33. shadowColor: 'rgba(0,0,0,0)',
  34. shadowOffsetY: 0
  35. },
  36. lineStyle: {
  37. width: 0
  38. }
  39. },
  40. backgroundColor: '#fff',
  41. color: '#5c6c7c',
  42. padding: [10, 10],
  43. extraCssText: 'box-shadow: 1px 0 2px 0 rgba(163,163,163,0.5)'
  44. },
  45. grid: {
  46. top: '15%'
  47. },
  48. xAxis: [{
  49. type: 'category',
  50. data: ['北京', '上海', '广州', '深圳', '香港', '澳门', '台湾'],
  51. axisLine: {
  52. lineStyle: {
  53. color: '#DCE2E8'
  54. }
  55. },
  56. axisTick: {
  57. show: false
  58. },
  59. axisLabel: {
  60. interval: 0,
  61. color: '#556677',
  62. // 默认x轴字体大小
  63. fontSize: 12,
  64. // margin:文字到x轴的距离
  65. margin: 15
  66. },
  67. axisPointer: {
  68. label: {
  69. // padding: [11, 5, 7],
  70. padding: [0, 0, 10, 0],
  71. // 这里的margin和axisLabel的margin要一致!
  72. margin: 15,
  73. // 移入时的字体大小
  74. fontSize: 12,
  75. backgroundColor: {
  76. type: 'linear',
  77. x: 0,
  78. y: 0,
  79. x2: 0,
  80. y2: 1,
  81. colorStops: [{
  82. offset: 0,
  83. color: '#fff' // 0% 处的颜色
  84. }, {
  85. // offset: 0.9,
  86. offset: 0.86,
  87. color: '#fff' // 0% 处的颜色
  88. }, {
  89. offset: 0.86,
  90. color: '#33c0cd' // 0% 处的颜色
  91. }, {
  92. offset: 1,
  93. color: '#33c0cd' // 100% 处的颜色
  94. }],
  95. global: false // 缺省为 false
  96. }
  97. }
  98. },
  99. boundaryGap: false
  100. }],
  101. yAxis: [{
  102. type: 'value',
  103. axisTick: {
  104. show: false
  105. },
  106. axisLine: {
  107. show: true,
  108. lineStyle: {
  109. color: '#DCE2E8'
  110. }
  111. },
  112. axisLabel: {
  113. color: '#556677',
  114. },
  115. splitLine: {
  116. show: false
  117. }
  118. }, {
  119. type: 'value',
  120. position: 'right',
  121. axisTick: {
  122. show: false
  123. },
  124. axisLabel: {
  125. color: '#556677',
  126. formatter: '{value}'
  127. },
  128. axisLine: {
  129. show: true,
  130. lineStyle: {
  131. color: '#DCE2E8'
  132. }
  133. },
  134. splitLine: {
  135. show: false
  136. }
  137. }],
  138. series: [{
  139. name: 'Adidas',
  140. type: 'line',
  141. data: [10, 10, 30, 12, 15, 3, 7],
  142. symbolSize: 1,
  143. symbol: 'circle',
  144. smooth: true,
  145. yAxisIndex: 0,
  146. showSymbol: true,
  147. lineStyle: {
  148. width: 5,
  149. color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{
  150. offset: 0,
  151. color: '#9effff'
  152. },
  153. {
  154. offset: 1,
  155. color: '#9E87FF'
  156. }
  157. ]),
  158. shadowColor: 'rgba(158,135,255, 0.3)',
  159. shadowBlur: 10,
  160. shadowOffsetY: 20
  161. },
  162. itemStyle: {
  163. color: colorList[0],
  164. borderColor: colorList[0]
  165. }
  166. }, {
  167. name: 'Nike',
  168. type: 'line',
  169. data: [5, 12, 11, 14, 25, 16, 10],
  170. symbolSize: 1,
  171. symbol: 'circle',
  172. smooth: true,
  173. yAxisIndex: 0,
  174. showSymbol: true,
  175. lineStyle: {
  176. width: 5,
  177. color: new echarts.graphic.LinearGradient(1, 1, 0, 0, [{
  178. offset: 0,
  179. color: '#73DD39'
  180. },
  181. {
  182. offset: 1,
  183. color: '#73DDFF'
  184. }
  185. ]),
  186. shadowColor: 'rgba(115,221,255, 0.3)',
  187. shadowBlur: 10,
  188. shadowOffsetY: 20
  189. },
  190. itemStyle: {
  191. color: colorList[1],
  192. borderColor: colorList[1]
  193. }
  194. },
  195. {
  196. name: '老北京布鞋',
  197. type: 'line',
  198. data: [150, 120, 170, 140, 500, 160, 110],
  199. symbolSize: 1,
  200. yAxisIndex: 1,
  201. symbol: 'circle',
  202. smooth: true,
  203. showSymbol: true,
  204. lineStyle: {
  205. width: 5,
  206. color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
  207. offset: 0,
  208. color: '#fe9a'
  209. },
  210. {
  211. offset: 1,
  212. color: '#fe9a8b'
  213. }
  214. ]),
  215. shadowColor: 'rgba(254,154,139, 0.3)',
  216. shadowBlur: 10,
  217. shadowOffsetY: 20
  218. },
  219. itemStyle: {
  220. color: colorList[2],
  221. borderColor: colorList[2]
  222. }
  223. }
  224. ]
  225. };
  226. line2.setOption(option);
  227. window.onresize = function() {
  228. line2.resize();
  229. }
  230. })