VisitRadar.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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: '300px',
  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: ['访问', '购买'],
  33. },
  34. tooltip: {},
  35. radar: {
  36. radius: '60%',
  37. splitNumber: 8,
  38. indicator: [
  39. {
  40. text: '电脑',
  41. max: 100,
  42. },
  43. {
  44. text: '充电器',
  45. max: 100,
  46. },
  47. {
  48. text: '耳机',
  49. max: 100,
  50. },
  51. {
  52. text: '手机',
  53. max: 100,
  54. },
  55. {
  56. text: 'Ipad',
  57. max: 100,
  58. },
  59. {
  60. text: '耳机',
  61. max: 100,
  62. },
  63. ],
  64. },
  65. series: [
  66. {
  67. type: 'radar',
  68. symbolSize: 0,
  69. areaStyle: {
  70. shadowBlur: 0,
  71. shadowColor: 'rgba(0,0,0,.2)',
  72. shadowOffsetX: 0,
  73. shadowOffsetY: 10,
  74. opacity: 1,
  75. },
  76. data: [
  77. {
  78. value: [90, 50, 86, 40, 50, 20],
  79. name: '访问',
  80. itemStyle: {
  81. color: '#b6a2de',
  82. },
  83. },
  84. {
  85. value: [70, 75, 70, 76, 20, 85],
  86. name: '购买',
  87. itemStyle: {
  88. color: '#5ab1ef',
  89. },
  90. },
  91. ],
  92. },
  93. ],
  94. });
  95. },
  96. { immediate: true }
  97. );
  98. </script>