echarts2.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <div>
  3. <div ref="echarts2" class="echarts2" style="height: 260px; width: 100%"></div>
  4. </div>
  5. </template>
  6. <style scoped></style>
  7. <script setup>
  8. import * as echarts from 'echarts'
  9. const echarts2 = ref()
  10. onMounted(() => {
  11. drawEcharts2()
  12. })
  13. function drawEcharts2() {
  14. var myChart2 = echarts.init(echarts2.value)
  15. var option2 = {
  16. tooltip: {
  17. trigger: 'axis',
  18. axisPointer: {
  19. lineStyle: {
  20. color: '#57617B'
  21. }
  22. }
  23. },
  24. legend: {
  25. data: [
  26. {
  27. name: '省重点'
  28. },
  29. {
  30. name: '市重点'
  31. },
  32. {
  33. name: '完成率'
  34. }
  35. ],
  36. top: '0%',
  37. textStyle: {
  38. color: 'rgba(255,255,255,0.9)'
  39. }
  40. },
  41. xAxis: [
  42. {
  43. type: 'category',
  44. data: [
  45. '1月',
  46. '2月',
  47. '3月',
  48. '4月',
  49. '5月',
  50. '6月',
  51. '7月',
  52. '8月',
  53. '9月',
  54. '10月',
  55. '11月',
  56. '12月'
  57. ],
  58. axisLine: {
  59. lineStyle: {
  60. color: 'rgba(255,255,255,.1)'
  61. }
  62. },
  63. axisLabel: {
  64. textStyle: {
  65. color: 'rgba(255,255,255,.6)',
  66. fontSize: '14'
  67. }
  68. }
  69. }
  70. ],
  71. yAxis: [
  72. {
  73. type: 'value',
  74. name: '金额',
  75. min: 0,
  76. max: 50,
  77. interval: 10,
  78. axisLabel: {
  79. show: true
  80. },
  81. axisLine: {
  82. lineStyle: {
  83. color: 'rgba(255,255,255,.4)'
  84. }
  85. }
  86. },
  87. {
  88. type: 'value',
  89. name: '完成率',
  90. show: true,
  91. axisLabel: {
  92. show: true
  93. },
  94. axisLine: {
  95. lineStyle: {
  96. color: 'rgba(255,255,255,.4)'
  97. }
  98. },
  99. splitLine: {
  100. show: true,
  101. lineStyle: {
  102. color: '#001e94'
  103. }
  104. }
  105. }
  106. ],
  107. grid: {
  108. top: '20%',
  109. right: '30',
  110. bottom: '30',
  111. left: '30'
  112. },
  113. series: [
  114. {
  115. name: '省重点',
  116. type: 'bar',
  117. data: [4, 6, 36, 6, 8, 6, 4, 6, 30, 6, 8, 12],
  118. barWidth: 'auto',
  119. itemStyle: {
  120. normal: {
  121. color: {
  122. type: 'linear',
  123. x: 0,
  124. y: 0,
  125. x2: 0,
  126. y2: 1,
  127. colorStops: [
  128. {
  129. offset: 0,
  130. color: '#609db8'
  131. },
  132. {
  133. offset: 1,
  134. color: '#609db8'
  135. }
  136. ],
  137. globalCoord: false
  138. }
  139. }
  140. }
  141. },
  142. {
  143. name: '市重点',
  144. type: 'bar',
  145. data: [4, 2, 34, 6, 8, 6, 4, 2, 32, 6, 8, 18],
  146. barWidth: 'auto',
  147. itemStyle: {
  148. normal: {
  149. color: {
  150. type: 'linear',
  151. x: 0,
  152. y: 0,
  153. x2: 0,
  154. y2: 1,
  155. colorStops: [
  156. {
  157. offset: 0,
  158. color: '#66b8a7'
  159. },
  160. {
  161. offset: 1,
  162. color: '#66b8a7'
  163. }
  164. ],
  165. globalCoord: false
  166. }
  167. }
  168. },
  169. barGap: '0'
  170. },
  171. {
  172. name: '完成率',
  173. type: 'line',
  174. yAxisIndex: 1,
  175. data: [100, 50, 80, 30, 90, 40, 70, 33, 100, 40, 80, 20],
  176. lineStyle: {
  177. normal: {
  178. width: 2
  179. }
  180. },
  181. itemStyle: {
  182. normal: {
  183. color: '#cdba00'
  184. }
  185. },
  186. smooth: true
  187. }
  188. ]
  189. }
  190. myChart2.setOption(option2)
  191. }
  192. </script>