echarts4.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <div>
  3. <div ref="echarts4" class="echarts4"></div>
  4. </div>
  5. </template>
  6. <style scoped>
  7. .echarts4 {
  8. height: 242px;
  9. width: 100%;
  10. }
  11. </style>
  12. <script setup>
  13. import * as echarts from 'echarts'
  14. const echarts4 = ref()
  15. onMounted(() => {
  16. drawEcharts4()
  17. })
  18. function drawEcharts4() {
  19. var myChart4 = echarts.init(echarts4.value)
  20. var option4 = {
  21. tooltip: {
  22. trigger: 'axis',
  23. axisPointer: {
  24. lineStyle: {
  25. color: '#57617B'
  26. }
  27. }
  28. },
  29. legend: {
  30. data: ['销售额', '利润'],
  31. top: '0',
  32. textStyle: {
  33. color: '#fff'
  34. },
  35. itemGap: 20
  36. },
  37. grid: {
  38. left: '0',
  39. right: '20',
  40. top: '10',
  41. bottom: '20',
  42. containLabel: true
  43. },
  44. xAxis: [
  45. {
  46. type: 'category',
  47. boundaryGap: false,
  48. axisLabel: {
  49. show: true,
  50. textStyle: {
  51. color: 'rgba(255,255,255,.6)'
  52. }
  53. },
  54. axisLine: {
  55. lineStyle: {
  56. color: 'rgba(255,255,255,.1)'
  57. }
  58. },
  59. data: [
  60. '1月',
  61. '2月',
  62. '3月',
  63. '4月',
  64. '5月',
  65. '6月',
  66. '7月',
  67. '8月',
  68. '9月',
  69. '10月',
  70. '11月',
  71. '12月'
  72. ]
  73. },
  74. {}
  75. ],
  76. yAxis: [
  77. {
  78. axisLabel: {
  79. show: true,
  80. textStyle: {
  81. color: 'rgba(255,255,255,.6)'
  82. }
  83. },
  84. axisLine: {
  85. lineStyle: {
  86. color: 'rgba(255,255,255,.1)'
  87. }
  88. },
  89. splitLine: {
  90. lineStyle: {
  91. color: 'rgba(255,255,255,.1)'
  92. }
  93. }
  94. }
  95. ],
  96. series: [
  97. {
  98. name: '销售额',
  99. type: 'line',
  100. smooth: true,
  101. symbol: 'circle',
  102. symbolSize: 5,
  103. showSymbol: false,
  104. lineStyle: {
  105. normal: {
  106. width: 2
  107. }
  108. },
  109. areaStyle: {
  110. normal: {
  111. color: new echarts.graphic.LinearGradient(
  112. 0,
  113. 0,
  114. 0,
  115. 1,
  116. [
  117. {
  118. offset: 0,
  119. color: 'rgba(24, 163, 64, 0.3)'
  120. },
  121. {
  122. offset: 0.8,
  123. color: 'rgba(24, 163, 64, 0)'
  124. }
  125. ],
  126. false
  127. ),
  128. shadowColor: 'rgba(0, 0, 0, 0.1)',
  129. shadowBlur: 10
  130. }
  131. },
  132. itemStyle: {
  133. normal: {
  134. color: '#cdba00',
  135. borderColor: 'rgba(137,189,2,0.27)',
  136. borderWidth: 12
  137. }
  138. },
  139. data: [220, 182, 191, 134, 150, 120, 110, 125, 145, 122, 165, 122]
  140. },
  141. {
  142. name: '利润',
  143. type: 'line',
  144. smooth: true,
  145. symbol: 'circle',
  146. symbolSize: 5,
  147. showSymbol: false,
  148. lineStyle: {
  149. normal: {
  150. width: 2
  151. }
  152. },
  153. areaStyle: {
  154. normal: {
  155. color: new echarts.graphic.LinearGradient(
  156. 0,
  157. 0,
  158. 0,
  159. 1,
  160. [
  161. {
  162. offset: 0,
  163. color: 'rgba(39, 122,206, 0.3)'
  164. },
  165. {
  166. offset: 0.8,
  167. color: 'rgba(39, 122,206, 0)'
  168. }
  169. ],
  170. false
  171. ),
  172. shadowColor: 'rgba(0, 0, 0, 0.1)',
  173. shadowBlur: 10
  174. }
  175. },
  176. itemStyle: {
  177. normal: {
  178. color: '#277ace',
  179. borderColor: 'rgba(0,136,212,0.2)',
  180. borderWidth: 12
  181. }
  182. },
  183. data: [120, 110, 125, 145, 122, 165, 122, 220, 182, 191, 134, 150]
  184. }
  185. ]
  186. }
  187. myChart4.setOption(option4)
  188. }
  189. </script>