-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchart_pie_a.js
274 lines (273 loc) · 9.2 KB
/
chart_pie_a.js
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
$(function() {
// 常量
var pcolor = yvan.pcolor // 主色
var pcolor50 = yvan.pcolor50
var pcolor400 = yvan.pcolor400
var pcolor500 = yvan.pcolor500
var ncolor = yvan.ncolor // 中性色
var acolor_p = yvan.acolor_p // 辅色紫色
var acolor_p400 = yvan.acolor_p400
var acolor_c = yvan.acolor_c // 辅色青色
var acolor_c600 = yvan.acolor_c600
var acolor_y = yvan.acolor_y // 辅色黄色
var acolor_y800 = yvan.acolor_y800 // 辅色橘黄色
var acolor_o = yvan.acolor_o // 辅色橙色
// 数据
var data1 = [{"name": "SUV", "value": "39.2"}, {"name": "三厢轿车", "value": "16.2"}, {"name": "纯越野车", "value": "12.0"}, {"name": "两厢轿车", "value": "9.0"}, {"name": "小型汽车/面包车", "value": "7.6"}, {"name": "MPV", "value": "6.2"}, {"name": "跑车", "value": "5.0"}, {"name": "房车", "value": "4.8"}]
var data2 = [{"name": "汽油车", "value": "58.5"}, {"name": "混合动力汽车", "value": "22.1"}, {"name": "纯电动汽车", "value": "10.1"}, {"name": "其他新能源汽车", "value": "6.4"}, {"name": "柴油车", "value": "2.8"}]
chart_init1()
chart_init2()
// 图表配置
function chart_init1() {
option = {
// backgroundColor:"#0B1837",
// color: ["#EAEA26", "#906BF9", "#FE5656", "#01E17E", "#3DD1F9", "#FFAD05"],
color: [acolor_y, acolor_p400, acolor_o, acolor_c600, pcolor500, acolor_y800],
// title: {
// text: '2018国内汽车销量品牌统计',
// left: '60',
// top: 0,
// textAlign: 'center',
// textStyle: {
// color: '#fff',
// fontSize: 14,
// fontWeight: 0
// }
// },
tooltip: {
trigger: 'item',
formatter: "{b} : {c} ({d}%)"
},
legend: [{
// orient: "vartical",
bottom: "7%",
itemWidth: 16,
itemHeight: 8,
itemGap: 16,
textStyle: {
color: '#A3E2F4',
fontSize: 12,
fontWeight: 0
},
data: data1.map(d => {
return d.name
})
}],
series: [{
type: 'pie',
// center: ['20%', '50%'],
radius: [100, 101],
hoverAnimation: false,
label: {
normal: {
show: true,
formatter: "{d}%",
textStyle: {
fontSize: 14,
},
position: 'outside'
},
emphasis: {
show: true
}
},
labelLine: {
normal: {
show: false,
length: 10,
length2: 0
},
emphasis: {
// show: false
}
},
name: "",
// data: [{
// name: '',
// value: 0,
// itemStyle: {
// normal: {
// color: pcolor
// }
// }
// }]
data: data1
},{
stack: 'a',
type: 'pie',
// center: ['20%', '50%'],
radius: [68, 82],
// roseType: 'radius',
zlevel: 10,
label: {
normal: {
show: true,
position: 'center',
formatter: "关注车型",
textStyle: {
fontSize: 20,
color: pcolor
}
},
emphasis: {
show: false
}
},
labelLine: {
normal: {
show: false,
length: 30,
length2: 44
},
emphasis: {
// show: false
}
},
itemStyle: {
normal: {
// color: '#c23531',
shadowBlur: 20,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
},
animationType: 'scale',
animationEasing: 'elasticOut',
animationDelay: function (idx) {
return Math.random() * 200;
},
data: data1
}, ]
}
let chart = echarts.init(document.getElementById('chart-pie-a-left'))
chart.setOption(option)
$(window).resize(function() {
chart.resize()
})
}
function chart_init2() {
option = {
// backgroundColor:"#0B1837",
// color: ["#EAEA26", "#906BF9", "#FE5656", "#01E17E", "#3DD1F9", "#FFAD05"],
color: [acolor_y, acolor_p400, acolor_o, acolor_c600, pcolor500, acolor_y800],
// title: {
// text: '2018国内汽车销量品牌统计',
// left: '60',
// top: 0,
// textAlign: 'center',
// textStyle: {
// color: '#fff',
// fontSize: 14,
// fontWeight: 0
// }
// },
tooltip: {
trigger: 'item',
formatter: "{b} : {c} ({d}%)"
},
legend: [{
// orient: "vartical",
bottom: "7%",
itemWidth: 16,
itemHeight: 8,
itemGap: 16,
textStyle: {
color: '#A3E2F4',
fontSize: 12,
fontWeight: 0
},
data: data2.map(d => {
return d.name
})
}],
series: [{
type: 'pie',
// center: ['20%', '50%'],
radius: [100, 101],
hoverAnimation: false,
label: {
normal: {
show: true,
formatter: "{d}%",
textStyle: {
fontSize: 14,
},
position: 'outside'
},
emphasis: {
show: true
}
},
labelLine: {
normal: {
show: false,
length: 10,
length2: 0
},
emphasis: {
// show: false
}
},
name: "",
// data: [{
// name: '',
// value: 0,
// itemStyle: {
// normal: {
// color: pcolor
// }
// }
// }]
data: data2
},{
stack: 'a',
type: 'pie',
// center: ['20%', '50%'],
radius: [68, 82],
// roseType: 'radius',
zlevel: 10,
label: {
normal: {
show: true,
position: 'center',
formatter: "动力类型",
textStyle: {
fontSize: 20,
color: pcolor
}
},
emphasis: {
show: false
}
},
labelLine: {
normal: {
show: false,
length: 30,
length2: 44
},
emphasis: {
// show: false
}
},
itemStyle: {
normal: {
// color: '#c23531',
shadowBlur: 20,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
},
animationType: 'scale',
animationEasing: 'elasticOut',
animationDelay: function (idx) {
return Math.random() * 200;
},
data: data2
}, ]
}
let chart = echarts.init(document.getElementById('chart-pie-a-right'))
chart.setOption(option)
$(window).resize(function() {
chart.resize()
})
}
}())