This repository has been archived by the owner on May 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
index-2.html
392 lines (380 loc) · 10.7 KB
/
index-2.html
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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>K8SMettup DashBoard</title>
<script src="./js/echarts.min.js"></script>
<script src="./js/jquery-2.2.0.min.js"></script>
</head>
<body>
<div style="width:1000px;margin:auto;">
<div id="main" style="width: 497px;height:400px;display: inline-flex;"></div>
<div id="pie" style="width: 497px;height:400px;display: inline-flex;"></div>
</div>
<div id="bar" style="width: 1000px;height:400px;margin:auto;"></div>
<div id="week" style="width: 1000px;height:550px;margin:auto; margin-top: 30px;"></div>
<div id="week_update" style="width: 1000px;height:550px;margin:auto; margin-top: 30px;"></div>
<script type="text/javascript">
// 基于准备好的dom,初始化echarts实例
var Chart = echarts.init(document.getElementById('main'));
var pieChart = echarts.init(document.getElementById('pie'));
var barChart = echarts.init(document.getElementById('bar'));
var weekChart = echarts.init(document.getElementById('week'));
var weekupdateChart = echarts.init(document.getElementById('week_update'));
// pie post
option = {
title : {
text: 'Kubernetes 文章任务汇总',
subtext: 'K8SMeetup 译者招募',
sublink: 'http://www.k8smeetup.com/recruit',
x:'center'
},
tooltip : {
trigger: 'item',
formatter: "{a} <br/>{b} : {c} ({d}%)"
},
legend: {
orient: 'vertical',
left: 'left',
data: []
},
series : [
{
name: '翻译文章汇总',
type: 'pie',
radius : '55%',
center: ['50%', '50%'],
data:[],
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
};
// 指定图表的配置项和数据
var pie_option = {
title : {
text: '翻译中文统计',
subtext: '微信译者招募',
sublink: 'https://mp.weixin.qq.com/s/1-YYrzEBK8JabxvU93Wf6Q',
x:'center'
},
tooltip : {
trigger: 'item',
formatter: "{a} <br/>{b} : {c} ({d}%)"
},
legend: {
type: 'scroll',
orient: 'vertical',
right: 10,
top: 20,
bottom: 20,
data: []
},
series : [
{
name: '姓名',
type: 'pie',
radius : '55%',
center: ['40%', '50%'],
data: [],
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
};
bar_option = {
title: {
text: 'Kubernetes 中文翻译汇总(单位:字)',
subtext: 'Kubernetes 中文站',
sublink: 'http://k8smeetup.github.io'
},
tooltip : {
trigger: 'axis',
axisPointer : { // 坐标轴指示器,坐标轴触发有效
type : 'shadow' // 默认为直线,可选为:'line' | 'shadow'
},
formatter: function (params) {
var tar = params[1];
return tar.name + '<br/>' + tar.seriesName + ' : ' + tar.value;
}
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: {
type : 'category',
splitLine: {show:false},
data : []
},
yAxis: {
type : 'value'
},
dataZoom: [
{
type: 'slider',
show: true,
start: 0,
end: 100,
handleSize: 8
},
{
type: 'inside',
start: 94,
end: 100
},
{
type: 'slider',
show: true,
yAxisIndex: 0,
filterMode: 'empty',
width: 12,
height: '70%',
handleSize: 8,
showDataShadow: false,
left: '93%'
}
],
series: []
};
// 每周翻译动态更新
var formatter = function (params,title) {
var content='', count =0;
for(var key in params){
if (params[key].value != 0){
content += params[key].seriesName+": "+params[key].value+" 字<br/>";
count+=params[key].value;
}
}
return content+"<b>"+title+": "+count+" 字</b>";
}
var radom_color = function () {
var color = [];
for(var i = 0; i < 31; i++){
// color.push("#"+Math.floor(Math.random()*(256*256*256-1)).toString(16));
color.push('#'+Math.floor(Math.random()*16777215).toString(16));
}
console.log(color);
return color;
}
// 每周新增的翻译
week_option = {
title: {
text: '每周新增翻译汇总'
},
tooltip : {
trigger: 'axis',
axisPointer : { // 坐标轴指示器,坐标轴触发有效
type : 'shadow' // 默认为直线,可选为:'line' | 'shadow'
},
formatter: function (params, ticket, callback) {
return params[0].name+"<br/>"+formatter(params, "本周总译字数");
}
},
color: radom_color(),
legend: {
top: 30,
data:[]
},
grid: {
top: 120,
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis : [
{
type : 'category',
data : []
}
],
yAxis : [
{
type : 'value'
}
],
dataZoom: [
{
type: 'slider',
show: true,
start: 0,
end: 100,
handleSize: 8
},
{
type: 'inside',
start: 94,
end: 100
},
{
type: 'slider',
show: true,
yAxisIndex: 0,
filterMode: 'empty',
width: 12,
height: '70%',
handleSize: 8,
showDataShadow: false,
left: '93%'
}
],
series : []
};
week_update_option = {
title: {
text: '每周更新翻译汇总'
},
tooltip : {
trigger: 'axis',
axisPointer : { // 坐标轴指示器,坐标轴触发有效
type : 'shadow' // 默认为直线,可选为:'line' | 'shadow'
},
formatter: function (params, ticket, callback) {
return params[0].name+"<br/>"+formatter(params, "本周更新字数");
}
},
color: radom_color(),
legend: {
top: 30,
data:[]
},
grid: {
top: 120,
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis : [
{
type : 'category',
data : []
}
],
yAxis : [
{
type : 'value'
}
],
dataZoom: [
{
type: 'slider',
show: true,
start: 0,
end: 100,
handleSize: 8
},
{
type: 'inside',
start: 94,
end: 100
},
{
type: 'slider',
show: true,
yAxisIndex: 0,
filterMode: 'empty',
width: 12,
height: '70%',
handleSize: 8,
showDataShadow: false,
left: '93%'
}
],
series : []
};
// 异步加载数据
$.get('./data-2.json').done(function (data) {
// Chart.setOption({
// legend: {
// data: data[0].legendData
// },
// series: [{
// data: data[0].seriesData
// }]
// });
// 填入数据
pieChart.setOption({
legend: {
data: data[0].legendData
},
series: [{
data: data[0].seriesData
}]
});
barChart.setOption({
xAxis: {
data: data[1].author
},
series: [
{
name: '辅助',
type: 'bar',
stack: '总量',
itemStyle: {
normal: {
barBorderColor: 'rgba(0,0,0,0)',
color: 'rgba(0,0,0,0)'
},
emphasis: {
barBorderColor: 'rgba(0,0,0,0)',
color: 'rgba(0,0,0,0)'
}
},
data: data[1].series_title
},
{
name: '翻译字数',
type: 'bar',
stack: '总量',
label: {
normal: {
show: true,
position: 'inside'
}
},
data: data[1].series_data
}
]
});
weekChart.setOption({
legend: {
data: data[2].legend
},
xAxis: {
data: data[2].category
},
series: data[2].series
});
weekupdateChart.setOption({
legend: {
data: data[3].legend
},
xAxis: {
data: data[3].category
},
series: data[3].series
});
});
// 使用刚指定的配置项和数据显示图表。
// Chart.setOption(option);
pieChart.setOption(pie_option);
barChart.setOption(bar_option);
weekChart.setOption(week_option);
weekupdateChart.setOption(week_update_option);
</script>
</body>
</html>