提交 | 用户 | 时间
|
e57a89
|
1 |
<template> |
懒 |
2 |
<div :class="className" :style="{height:height,width:width}" /> |
|
3 |
</template> |
|
4 |
|
|
5 |
<script> |
|
6 |
import * as echarts from 'echarts' |
|
7 |
require('echarts/theme/macarons') // echarts theme |
|
8 |
import resize from './mixins/resize' |
|
9 |
|
|
10 |
const animationDuration = 3000 |
|
11 |
|
|
12 |
export default { |
|
13 |
mixins: [resize], |
|
14 |
props: { |
|
15 |
className: { |
|
16 |
type: String, |
|
17 |
default: 'chart' |
|
18 |
}, |
|
19 |
width: { |
|
20 |
type: String, |
|
21 |
default: '100%' |
|
22 |
}, |
|
23 |
height: { |
|
24 |
type: String, |
|
25 |
default: '300px' |
|
26 |
} |
|
27 |
}, |
|
28 |
data() { |
|
29 |
return { |
|
30 |
chart: null |
|
31 |
} |
|
32 |
}, |
|
33 |
mounted() { |
|
34 |
this.$nextTick(() => { |
|
35 |
this.initChart() |
|
36 |
}) |
|
37 |
}, |
|
38 |
beforeDestroy() { |
|
39 |
if (!this.chart) { |
|
40 |
return |
|
41 |
} |
|
42 |
this.chart.dispose() |
|
43 |
this.chart = null |
|
44 |
}, |
|
45 |
methods: { |
|
46 |
initChart() { |
|
47 |
this.chart = echarts.init(this.$el, 'macarons') |
|
48 |
|
|
49 |
this.chart.setOption({ |
|
50 |
tooltip: { |
|
51 |
trigger: 'axis', |
|
52 |
axisPointer: { // 坐标轴指示器,坐标轴触发有效 |
|
53 |
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow' |
|
54 |
} |
|
55 |
}, |
|
56 |
radar: { |
|
57 |
radius: '66%', |
|
58 |
center: ['50%', '42%'], |
|
59 |
splitNumber: 8, |
|
60 |
splitArea: { |
|
61 |
areaStyle: { |
|
62 |
color: 'rgba(127,95,132,.3)', |
|
63 |
opacity: 1, |
|
64 |
shadowBlur: 45, |
|
65 |
shadowColor: 'rgba(0,0,0,.5)', |
|
66 |
shadowOffsetX: 0, |
|
67 |
shadowOffsetY: 15 |
|
68 |
} |
|
69 |
}, |
|
70 |
indicator: [ |
|
71 |
{ name: 'Sales', max: 10000 }, |
|
72 |
{ name: 'Administration', max: 20000 }, |
|
73 |
{ name: 'Information Techology', max: 20000 }, |
|
74 |
{ name: 'Customer Support', max: 20000 }, |
|
75 |
{ name: 'Development', max: 20000 }, |
|
76 |
{ name: 'Marketing', max: 20000 } |
|
77 |
] |
|
78 |
}, |
|
79 |
legend: { |
|
80 |
left: 'center', |
|
81 |
bottom: '10', |
|
82 |
data: ['Allocated Budget', 'Expected Spending', 'Actual Spending'] |
|
83 |
}, |
|
84 |
series: [{ |
|
85 |
type: 'radar', |
|
86 |
symbolSize: 0, |
|
87 |
areaStyle: { |
|
88 |
normal: { |
|
89 |
shadowBlur: 13, |
|
90 |
shadowColor: 'rgba(0,0,0,.2)', |
|
91 |
shadowOffsetX: 0, |
|
92 |
shadowOffsetY: 10, |
|
93 |
opacity: 1 |
|
94 |
} |
|
95 |
}, |
|
96 |
data: [ |
|
97 |
{ |
|
98 |
value: [5000, 7000, 12000, 11000, 15000, 14000], |
|
99 |
name: 'Allocated Budget' |
|
100 |
}, |
|
101 |
{ |
|
102 |
value: [4000, 9000, 15000, 15000, 13000, 11000], |
|
103 |
name: 'Expected Spending' |
|
104 |
}, |
|
105 |
{ |
|
106 |
value: [5500, 11000, 12000, 15000, 12000, 12000], |
|
107 |
name: 'Actual Spending' |
|
108 |
} |
|
109 |
], |
|
110 |
animationDuration: animationDuration |
|
111 |
}] |
|
112 |
}) |
|
113 |
} |
|
114 |
} |
|
115 |
} |
|
116 |
</script> |