rate3D.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <div ref="chart" class="item" style="width: 94px; height:138px" />
  3. </template>
  4. <script>
  5. import * as echarts from "echarts";
  6. export default {
  7. props: {
  8. data: Number,
  9. text: String,
  10. title: String
  11. },
  12. data() {
  13. return {
  14. chart: null,
  15. };
  16. },
  17. mounted() {
  18. const chartDom = this.$refs.chart;
  19. // // 初始化图表实例
  20. this.chart = echarts.init(chartDom);
  21. this.initChart();
  22. },
  23. methods: {
  24. initChart() {
  25. const option = {
  26. // backgroundColor: '#111',
  27. title: [{
  28. text: this.title,
  29. x: 'center',
  30. top: '84%',
  31. textStyle: {
  32. color: '#fff',
  33. fontSize:12,
  34. // fontWeight: '100',
  35. }
  36. }, {
  37. text: this.text,
  38. x: 'center',
  39. top: '42%',
  40. textStyle: {
  41. fontSize: '12',
  42. color: '#fdf914',
  43. fontFamily: 'Lato',
  44. // foontWeight: '600',
  45. },
  46. }],
  47. polar: {
  48. radius: ['38%', '53%'],
  49. center: ['50%', '50%'],
  50. },
  51. angleAxis: {
  52. max: 100,
  53. show: false,
  54. },
  55. radiusAxis: {
  56. type: 'category',
  57. show: true,
  58. axisLabel: {
  59. show: false,
  60. },
  61. axisLine: {
  62. show: false,
  63. },
  64. axisTick: {
  65. show: false
  66. },
  67. },
  68. series: [
  69. {
  70. name: '',
  71. type: 'bar',
  72. roundCap: true,
  73. barWidth: 60,
  74. showBackground: true,
  75. backgroundStyle: {
  76. color: 'rgba(66, 66, 66, .3)',
  77. },
  78. data: [this.data],
  79. coordinateSystem: 'polar',
  80. itemStyle: {
  81. normal: {
  82. color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{
  83. offset: 0,
  84. color: '#fdf914'
  85. }, {
  86. offset: 1,
  87. color: '#38a700'
  88. }]),
  89. }
  90. }
  91. },
  92. {
  93. type: 'gauge',
  94. name: '',
  95. radius: '100%',
  96. startAngle: '0',
  97. endAngle: '-359.99',
  98. splitNumber: '200',
  99. center: ['50%', '50%'],
  100. pointer: {
  101. show: false
  102. },
  103. title: {
  104. show: false
  105. },
  106. detail: {
  107. show: false
  108. },
  109. data: [{
  110. value: 95,
  111. name: ''
  112. }],
  113. axisLine: {
  114. lineStyle: {
  115. width: 20,
  116. opacity: 0
  117. }
  118. },
  119. axisTick: {
  120. show: false
  121. },
  122. splitLine: {
  123. show: true,
  124. length: 0,
  125. lineStyle: {
  126. color: {
  127. type: 'linear',
  128. x: 1,
  129. y: 0,
  130. x2: 0,
  131. y2: 0,
  132. colorStops: [{
  133. offset: 0,
  134. color: '#111'
  135. }, {
  136. offset: 0.5,
  137. color: 'rgba(66, 66, 66, 1)',
  138. }, {
  139. offset: 1,
  140. color: '#111'
  141. }],
  142. globalCoord: false
  143. },
  144. width: 1,
  145. type: 'solid',
  146. },
  147. },
  148. axisLabel: {
  149. show: false
  150. }
  151. },
  152. {
  153. name: '',
  154. type: 'pie',
  155. startAngle: 90,
  156. radius: ['100%', '82%'],
  157. hoverAnimation: false,
  158. center: ['50%', '50%'],
  159. itemStyle: {
  160. normal: {
  161. labelLine: {
  162. show: false
  163. },
  164. color: 'rgba(66, 66, 66, .4)',
  165. shadowBlur: 10,
  166. shadowColor: 'rgba(253, 249, 20, .3)',
  167. }
  168. },
  169. data: [{
  170. value: 100,
  171. }]
  172. },
  173. {
  174. name: '',
  175. type: 'pie',
  176. startAngle: 90,
  177. radius: ['62.5%', '64%'],
  178. hoverAnimation: false,
  179. center: ['50%', '50%'],
  180. itemStyle: {
  181. normal: {
  182. labelLine: {
  183. show: false
  184. },
  185. color: 'rgba(66, 66, 66, .3)',
  186. shadowBlur: 10,
  187. shadowColor: 'rgba(253, 249, 20, .3)',
  188. }
  189. },
  190. data: [{
  191. value: 100,
  192. }]
  193. },
  194. {
  195. name: '',
  196. type: 'pie',
  197. startAngle: 90,
  198. radius: ['64.5%', '65.8%'],
  199. hoverAnimation: false,
  200. center: ['50%', '50%'],
  201. itemStyle: {
  202. normal: {
  203. labelLine: {
  204. show: false
  205. },
  206. color: 'rgba(66, 66, 66, .2)',
  207. shadowBlur: 10,
  208. shadowColor: 'rgba(253, 249, 20, .3)',
  209. }
  210. },
  211. data: [{
  212. value: 100,
  213. }]
  214. },
  215. {
  216. name: '',
  217. type: 'pie',
  218. startAngle: 90,
  219. radius: ['66.5%', '67.5%'],
  220. hoverAnimation: false,
  221. center: ['50%', '50%'],
  222. itemStyle: {
  223. normal: {
  224. labelLine: {
  225. show: false
  226. },
  227. color: 'rgba(66, 66, 66, .1)',
  228. shadowBlur: 10,
  229. shadowColor: 'rgba(253, 249, 20, .3)',
  230. }
  231. },
  232. data: [{
  233. value: 100,
  234. }]
  235. },
  236. ]
  237. };
  238. this.chart.setOption(option);
  239. //自适应图表
  240. window.onresize = this.chart.resize;
  241. },
  242. numb(){
  243. myChart.setOption(option, true)
  244. },
  245. }
  246. };
  247. </script>
  248. <style scoped></style>