SaleRadar.vue 2.1 KB

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