SaleRadar.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <Card title="销售统计" :loading="loading">
  3. <div ref="chartRef" :style="{ width, height }"></div>
  4. </Card>
  5. </template>
  6. <script lang="ts">
  7. import { defineComponent, Ref, ref, watch } from 'vue';
  8. import { Card } from 'ant-design-vue';
  9. import { useECharts } from '/@/hooks/web/useECharts';
  10. export default defineComponent({
  11. components: { Card },
  12. props: {
  13. loading: Boolean,
  14. width: {
  15. type: String as PropType<string>,
  16. default: '100%',
  17. },
  18. height: {
  19. type: String as PropType<string>,
  20. default: '400px',
  21. },
  22. },
  23. setup(props) {
  24. const chartRef = ref<HTMLDivElement | null>(null);
  25. const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>);
  26. watch(
  27. () => props.loading,
  28. () => {
  29. if (props.loading) {
  30. return;
  31. }
  32. setOptions({
  33. backgroundColor: '#fff',
  34. legend: {
  35. bottom: 0,
  36. data: ['Visits', 'Sales'],
  37. },
  38. tooltip: {},
  39. radar: {
  40. radius: '60%',
  41. splitNumber: 8,
  42. indicator: [
  43. {
  44. text: '2017',
  45. max: 100,
  46. },
  47. {
  48. text: '2017',
  49. max: 100,
  50. },
  51. {
  52. text: '2018',
  53. max: 100,
  54. },
  55. {
  56. text: '2019',
  57. max: 100,
  58. },
  59. {
  60. text: '2020',
  61. max: 100,
  62. },
  63. {
  64. text: '2021',
  65. max: 100,
  66. },
  67. ],
  68. },
  69. series: [
  70. {
  71. type: 'radar',
  72. symbolSize: 0,
  73. areaStyle: {
  74. shadowBlur: 0,
  75. shadowColor: 'rgba(0,0,0,.2)',
  76. shadowOffsetX: 0,
  77. shadowOffsetY: 10,
  78. opacity: 1,
  79. },
  80. data: [
  81. {
  82. value: [90, 50, 86, 40, 50, 20],
  83. name: 'Visits',
  84. itemStyle: {
  85. color: '#b6a2de',
  86. },
  87. },
  88. {
  89. value: [70, 75, 70, 76, 20, 85],
  90. name: 'Sales',
  91. itemStyle: {
  92. color: '#67e0e3',
  93. },
  94. },
  95. ],
  96. },
  97. ],
  98. });
  99. },
  100. { immediate: true }
  101. );
  102. return { chartRef };
  103. },
  104. });
  105. </script>