RaddarChart.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <div :class="className" :style="{height:height,width:width}"/>
  3. </template>
  4. <script>
  5. import * as echarts from 'echarts'
  6. require('echarts/theme/macarons') // echarts theme
  7. import resize from '../mixins/resize'
  8. import {procedureCount} from "@/api/common/homedataCbpb";
  9. const animationDuration = 3000
  10. export default {
  11. mixins: [resize],
  12. props: {
  13. className: {
  14. type: String,
  15. default: 'chart'
  16. },
  17. width: {
  18. type: String,
  19. default: '100%'
  20. },
  21. height: {
  22. type: String,
  23. default: '210px'
  24. }
  25. },
  26. data() {
  27. return {
  28. chart: null,
  29. chartData: {},
  30. color: [
  31. '#87CA8B',
  32. '#58B1FF',
  33. '#FBD44A',
  34. '#7485E5',
  35. '#AEE5B1',
  36. '#81C4FF',
  37. '#AAD7FF',
  38. '#FFE791',
  39. '#9AA6EA',
  40. ],
  41. dataIn: [
  42. // 外层数据
  43. ],
  44. dataOut: []
  45. }
  46. },
  47. created() {
  48. },
  49. mounted() {
  50. this.$nextTick(() => {
  51. procedureCount().then(res => {
  52. this.dataOut = [
  53. {value: res.data.appNum, name: res.data.app},
  54. {value: res.data.trainNum, name: res.data.train},
  55. {value: res.data.excelNum, name: res.data.excel},
  56. {value: res.data.fileNum, name: res.data.file},
  57. {value: res.data.guideNum, name: res.data.guide},
  58. {value: res.data.fingerpostNum, name: res.data.fingerpost}
  59. ]
  60. this.initChart()
  61. })
  62. })
  63. },
  64. beforeDestroy() {
  65. if (!this.chart) {
  66. return
  67. }
  68. this.chart.dispose()
  69. this.chart = null
  70. },
  71. methods: {
  72. initChart() {
  73. this.chart = echarts.init(this.$el, 'macarons')
  74. this.chart.setOption({
  75. color: this.color,
  76. tooltip: {
  77. trigger: 'item',
  78. formatter: "{b}: {c} " + " | " + "{d}%"
  79. },
  80. title:
  81. {
  82. text: '',
  83. }
  84. ,
  85. legend: {
  86. orient: 'vertical',
  87. left: 'left',
  88. itemWidth: 10,
  89. itemHeight: 10,
  90. textStyle: {
  91. fontSize: 12,
  92. padding:[0,0]
  93. },
  94. selectedMode: true,
  95. data: ['程序总汇', '指南总汇', '指导书总汇', '附件总汇', '表格总汇', '培训材料'],
  96. },
  97. series: [
  98. {
  99. name: '',
  100. type: 'pie',
  101. selectedMode: 'single',
  102. radius: ['20%', '80%'],
  103. label: {
  104. position: 'outside',
  105. fontSize: 10,
  106. },
  107. animationEasing: 'cubicInOut',
  108. animationDuration: 1300,
  109. labelLine: {
  110. show: true
  111. },
  112. data: this.dataOut
  113. }
  114. ],
  115. })
  116. }
  117. }
  118. }
  119. </script>