1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
| <script lang="ts" setup>
| import type { EchartsUIType } from '@vben/plugins/echarts';
|
| import { onMounted, ref } from 'vue';
|
| import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
| const props = defineProps({
| data: {
| default: () => [],
| type: Array as any,
| },
| });
|
| const chartRef = ref<EchartsUIType>();
| const { renderEcharts } = useEcharts(chartRef);
|
| onMounted(() => {
| const data = props.data
| .filter((o) => o.data)
| .map((o) => ({ name: o.name, value: o.data }))
| .sort((a, b) => a.value - b.value);
| renderEcharts({
| series: [
| {
| animationDelay() {
| return Math.random() * 400;
| },
| animationEasing: 'exponentialInOut',
| animationType: 'scale',
| center: ['50%', '50%'],
| data,
| name: '用户数',
| radius: '60%',
| roseType: 'radius',
| type: 'pie',
| },
| ],
| legend: {
| show: true,
| right: 0,
| },
| tooltip: {
| trigger: 'item',
| },
| });
| });
| </script>
|
| <template>
| <EchartsUI ref="chartRef" height="400px" />
| </template>
|
|