recycle-proportion.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <v-chart
  3. class="flex-1"
  4. ref="saleChartRef"
  5. style="height: 380px"
  6. :option="options"
  7. />
  8. </template>
  9. <script setup>
  10. import { computed } from 'vue';
  11. import VChart from 'vue-echarts';
  12. import { use } from 'echarts/core';
  13. import { CanvasRenderer } from 'echarts/renderers';
  14. import { PieChart } from 'echarts/charts';
  15. import {
  16. GridComponent,
  17. TooltipComponent,
  18. LegendComponent,
  19. TitleComponent
  20. } from 'echarts/components';
  21. // 按需加载echarts
  22. use([
  23. CanvasRenderer,
  24. PieChart,
  25. GridComponent,
  26. TooltipComponent,
  27. LegendComponent,
  28. TitleComponent
  29. ]);
  30. const props = defineProps({
  31. data: {
  32. type: Object,
  33. default: () => ({})
  34. }
  35. });
  36. const options = computed(() => ({
  37. title: {
  38. text: '回收占比',
  39. textStyle: {
  40. color: '#363636',
  41. fontSize: 14,
  42. fontWeight: 'normal'
  43. }
  44. },
  45. legend: {
  46. bottom: 'bottom',
  47. orient: 'horizontal',
  48. itemGap: 20,
  49. textStyle: {
  50. fontSize: 12
  51. }
  52. },
  53. tooltip: {
  54. trigger: 'item',
  55. formatter: '{a} <br/>{b}: {c} ({d}%)'
  56. },
  57. series: [
  58. {
  59. name: '回收占比',
  60. type: 'pie',
  61. radius: [50, 100],
  62. center: ['50%', '45%'],
  63. avoidLabelOverlap: false,
  64. itemStyle: {
  65. borderRadius: 4
  66. },
  67. label: {
  68. show: true,
  69. position: 'outside',
  70. formatter: function(params) {
  71. return params.name + '\n' + params.value;
  72. },
  73. fontSize: 12,
  74. lineHeight: 14
  75. },
  76. emphasis: {
  77. label: {
  78. show: true,
  79. fontSize: '14',
  80. fontWeight: 'bold'
  81. }
  82. },
  83. data: [
  84. {
  85. value: props.data.recycleingNum || 0,
  86. name: '已加入回收书单 (正在回收)',
  87. itemStyle: { color: '#409EFF' }
  88. },
  89. {
  90. value: props.data.notInListNum || 0,
  91. name: '未加入回收书单',
  92. itemStyle: { color: '#20B2AA' }
  93. },
  94. {
  95. value: props.data.blackNum || 0,
  96. name: '黑名单',
  97. itemStyle: { color: '#67C23A' }
  98. },
  99. {
  100. value: props.data.fullPauseNum || 0,
  101. name: '已加入回收书单 (收满暂停)',
  102. itemStyle: { color: '#E6A23C' }
  103. },
  104. {
  105. value: props.data.pauseNum || 0,
  106. name: '已加入回收书单 (手动暂停)',
  107. itemStyle: { color: '#F56C6C' }
  108. }
  109. ]
  110. }
  111. ]
  112. }));
  113. </script>