pie.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <el-row >
  3. <div
  4. id="index1"
  5. style="width:360px;height:360px;margin:-78px 0 0 134px;"
  6. ></div>
  7. </el-row>
  8. </template>
  9. <script>
  10. import * as echarts from 'echarts';
  11. export default {
  12. props: ["resData"],
  13. data() {
  14. return {
  15. data:[]
  16. };
  17. },
  18. watch: {
  19. resData(val,old){
  20. this.data = val
  21. this.getData()
  22. }
  23. },
  24. methods: {
  25. getData() {
  26. let myChart = echarts.init(document.getElementById("index1"));
  27. let option = {
  28. color: [
  29. '#F8B13D',
  30. 'rgba(46,52,64,1)',
  31. ],
  32. title: {
  33. //text: data.attendeeIsSign,
  34. text: this.data[0].value + '%',
  35. textStyle: {
  36. color: '#E6EFFF',
  37. fontSize: 25
  38. },
  39. subtext: '使用率',
  40. subtextStyle: {
  41. color: '#E6EFFF',
  42. fontSize: 20
  43. },
  44. itemGap: 10, // 主副标题距离
  45. left: 'center',
  46. top: '42%'
  47. },
  48. tooltip: {
  49. trigger: 'item'
  50. },
  51. legend: {
  52. top: '70%',
  53. left: 'center',
  54. textStyle: {
  55. color: "#FFF"
  56. }
  57. },
  58. series: [
  59. {
  60. name: '',
  61. type: 'pie',
  62. radius: ['30%', '35%'],
  63. avoidLabelOverlap: false,
  64. label: {
  65. show: false,
  66. position: 'center'
  67. },
  68. emphasis: {
  69. // label: {
  70. // show: true,
  71. // fontSize: '40',
  72. // fontWeight: 'bold'
  73. // }
  74. },
  75. labelLine: {
  76. show: false
  77. },
  78. data: this.data
  79. }
  80. ]
  81. };
  82. myChart.setOption(option);
  83. option && myChart.setOption(option);
  84. setTimeout(function () {
  85. window.onresize = function () {
  86. myChart.resize();
  87. };
  88. }, 200);
  89. },
  90. },
  91. };
  92. </script>