9.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <div id="myChartold9" style="width: 100%; height: 100%; "></div>
  3. </template>
  4. <script>
  5. export default {
  6. //老年人可支配收入统计
  7. name: "OldPersonIncomeControlCount",
  8. data() {
  9. return {
  10. dataArr: [
  11. { label: '5000元以下', value: 25 },
  12. { label: '5000~10000元', value: 50 },
  13. { label: '10000元以上', value: 25 }
  14. ],
  15. colorArr: [
  16. { color1: '#4625FF', color2: '#6DC0FF' },
  17. { color1: '#f6a314', color2: '#f4ff81' },
  18. { color1: '#45ff00', color2: '#8bffbb' }
  19. ]
  20. }
  21. },
  22. mounted() {
  23. const seriesArr = [];
  24. const offset = 30;
  25. for(let i = 0; i < this.dataArr.length; i++) {
  26. const d = this.dataArr[i];
  27. // seriesArr.push({
  28. // type: 'pie',
  29. // radius: [0, 50],
  30. // center: [`${50 - offset + i * offset}%`, '50%'],
  31. // labelLine: {
  32. // show: false
  33. // },
  34. // data: [{
  35. // value: d.value,
  36. // // label: {
  37. // // show: true,
  38. // // position: 'center',
  39. // // formatter:() => {
  40. // // return `${d.value}%`
  41. // // },
  42. // // fontSize: '32',
  43. // // fontWeight: 'bold',
  44. // // color: '#fff'
  45. // // },
  46. // itemStyle: {
  47. // color: new this.$echarts.graphic.LinearGradient(0, 1, 0, 0, [{
  48. // offset: 0,
  49. // color: this.colorArr[i].color1
  50. // }, {
  51. // offset: 1,
  52. // color: this.colorArr[i].color2
  53. // }])
  54. // }
  55. // }],
  56. // z: 2
  57. // });
  58. seriesArr.push({
  59. type: 'pictorialBar',
  60. symbol: i == 0 ? `image://${require("../../assets/oldStatistics/37.png")}` : ( i == 1 ? `image://${require("../../assets/oldStatistics/38.png")}` : `image://${require("../../assets/oldStatistics/39.png")}` ),
  61. symbolSize: [72, 72],
  62. data: [ { value: 1, symbolPosition: 'start', symbolOffset: [`${i == 0 ? -137 : ( i == 1 ? 0 : 137 )}`, -70] } ],
  63. label: {
  64. normal: {
  65. show: true,
  66. position: "top",
  67. offset: [i == 0 ? -135 : ( i == 1 ? 0 : 135 ), i == 0 ? 130 : ( i == 1 ? -30 : 130 )],
  68. textStyle: {
  69. fontSize: 20,
  70. color: '#fff'
  71. },
  72. formatter: `${d.label}`
  73. }
  74. },
  75. z: 2
  76. });
  77. seriesArr.push({
  78. type: 'pie',
  79. radius: [58, 78],
  80. startAngle: '180',
  81. clockwise: !(i % 2),
  82. center: [`${50 - 29.5 + i * offset}%`, '46%'],
  83. labelLine: {
  84. show: false
  85. },
  86. data: [{
  87. value: d.value / 2,
  88. label: {
  89. show: true,
  90. position: 'center',
  91. formatter:() => {
  92. return `${d.value}%`
  93. },
  94. fontSize: '26',
  95. fontWeight: 'bold',
  96. color: '#fff'
  97. },
  98. itemStyle: {
  99. color: new this.$echarts.graphic.LinearGradient(0, 1, 0, 0, [{
  100. offset: 0,
  101. color: this.colorArr[i].color1
  102. }, {
  103. offset: 1,
  104. color: this.colorArr[i].color2
  105. }])
  106. }
  107. },
  108. {
  109. value: 50 - (d.value * 50 / 100).toFixed(1),
  110. itemStyle: {
  111. color: 'rgba(184, 255, 205, 0.1)'
  112. }
  113. },
  114. {
  115. value: 50,
  116. itemStyle: {
  117. color: "transparent"
  118. }
  119. }],
  120. z: 2
  121. });
  122. }
  123. let myChart = this.$echarts.init(document.getElementById('myChartold9'));
  124. myChart.setOption({
  125. xAxis: {
  126. type: 'category',
  127. splitLine: {
  128. show: false
  129. },
  130. axisLine: {
  131. show: false
  132. },
  133. axisLabel: {
  134. show: false
  135. },
  136. axisTick: {
  137. show: false
  138. }
  139. },
  140. yAxis: {
  141. type: 'value',
  142. max: 200,
  143. splitLine: {
  144. show: false
  145. },
  146. axisLine: {
  147. show: false
  148. },
  149. axisTick: {
  150. show: false
  151. },
  152. axisLabel: {
  153. show: false
  154. }
  155. },
  156. series: seriesArr
  157. });
  158. }
  159. }
  160. </script>
  161. <style scoped>
  162. </style>