chartState.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <div id="chart-state" style="width: 100%; height: 100%"></div>
  3. </template>
  4. <script>
  5. export default {
  6. name: "chartState",
  7. data() {
  8. return {
  9. myChart: null
  10. }
  11. },
  12. methods: {
  13. init() {
  14. let options = {
  15. graphic: [
  16. {
  17. type: 'text',
  18. left: '45%',
  19. top: '42%',
  20. style: {
  21. text: '总存栏',
  22. fontSize: 14,
  23. fill: 'rgb(192, 188, 189)'
  24. }
  25. },
  26. {
  27. type: 'text',
  28. left: '45%',
  29. top: '50%',
  30. style: {
  31. text: '120',
  32. fontSize: 16,
  33. fontWeight: 700,
  34. fill: 'rgb(192, 188, 189)'
  35. }
  36. }
  37. ],
  38. series: [
  39. {
  40. name: '',
  41. type: 'pie',
  42. hoverAnimation: false,
  43. legendHoverLink: false,
  44. cursor: 'default',
  45. radius: ['45%', '30%'],
  46. center: ['50%', '50%'],
  47. color: [
  48. 'rgba(0, 150, 254, 0.2)',
  49. 'rgba(2, 205, 206, 0.2)',
  50. 'rgba(253, 160, 0, 0.2)',
  51. 'rgba(191, 40, 18, 0.2)',
  52. ],
  53. label: {
  54. show: false,
  55. },
  56. labelLine: {
  57. show: false,
  58. },
  59. zlevel: 1,
  60. itemStyle: {
  61. normal: {
  62. borderColor: '#0a1a2a',
  63. },
  64. ellipsis: {
  65. borderColor: '#0a1a2a',
  66. },
  67. },
  68. tooltip: {
  69. show: false,
  70. },
  71. data: [
  72. {
  73. value: 41,
  74. name: '',
  75. },
  76. {
  77. value: 20,
  78. name: '',
  79. },
  80. {
  81. value: 20,
  82. name: '',
  83. },
  84. {
  85. value: 20,
  86. name: '',
  87. },
  88. ],
  89. },
  90. {
  91. name: '',
  92. type: 'pie',
  93. zlevel: 2,
  94. cursor: 'default',
  95. hoverAnimation: false,
  96. legendHoverLink: false,
  97. radius: ['60%', '45%'],
  98. center: ['50%', '50%'],
  99. color: [
  100. 'rgba(0, 150, 254, 0.9)',
  101. 'rgba(2, 205, 206, 0.9)',
  102. 'rgba(253, 160, 0, 0.9)',
  103. 'rgba(191, 40, 18, 0.9)',
  104. ],
  105. label: {
  106. show: false,
  107. },
  108. labelLine: {
  109. show: false,
  110. },
  111. itemStyle: {
  112. normal: {
  113. // shadowBlur: 15,
  114. // shadowColor: 'rgba(0, 0, 0, 0.5)',
  115. borderColor: '#0a1a2a',
  116. // borderWidth:'10',
  117. },
  118. ellipsis: {
  119. borderColor: '#0a1a2a',
  120. },
  121. },
  122. tooltip: {
  123. show: false,
  124. },
  125. data: [
  126. {
  127. value: 41,
  128. name: '',
  129. },
  130. {
  131. value: 20,
  132. name: '',
  133. },
  134. {
  135. value: 20,
  136. name: '',
  137. },
  138. {
  139. value: 20,
  140. name: '',
  141. },
  142. ],
  143. },
  144. {
  145. name: 'title',
  146. type: 'pie',
  147. zlevel: 3,
  148. hoverAnimation: false,
  149. legendHoverLink: false,
  150. radius: ['80%', '60%'],
  151. center: ['50%', '50%'],
  152. color: ['rgba(0, 150, 254, 1)', 'rgba(2, 205, 206, 1)', 'rgba(253, 160, 0, 1)', 'rgba(191, 40, 18, 1)'],
  153. label: {
  154. show: true,
  155. formatter: (params) => {
  156. return `
  157. ${params.name}: ${params.percent}%
  158. ${params.data.value}个
  159. `;
  160. },
  161. padding:[0,-30],
  162. textStyle:{
  163. lineHeight: 25
  164. }
  165. },
  166. labelLine: {
  167. show: true,
  168. // showAbove:true,
  169. length: 30,
  170. length2: 50,
  171. },
  172. itemStyle: {
  173. shadowBlur: 15,
  174. shadowColor: 'rgba(0, 0, 0, 0.3)',
  175. borderColor: '#0a1a2a',
  176. },
  177. data: [
  178. {
  179. value: 41,
  180. name: '低级',
  181. label: {
  182. color: '#fff',
  183. },
  184. },
  185. {
  186. value: 20,
  187. name: '中级',
  188. label: {
  189. color: '#fff',
  190. },
  191. },
  192. {
  193. value: 20,
  194. name: '⾼级',
  195. label: {
  196. color: '#fff',
  197. },
  198. },
  199. {
  200. value: 20,
  201. name: '极⾼',
  202. label: {
  203. color: '#fff',
  204. },
  205. },
  206. ],
  207. },
  208. ],
  209. }
  210. this.myChart.setOption(options)
  211. }
  212. },
  213. mounted() {
  214. this.myChart = this.$echarts.init(document.getElementById('chart-state'));
  215. this.init()
  216. let that = this;
  217. window.addEventListener('resize', function() {
  218. that.myChart.resize();
  219. })
  220. }
  221. }
  222. </script>
  223. <style scoped>
  224. </style>