forked from apache/echarts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
parallel-aqi.html
173 lines (166 loc) · 6.85 KB
/
parallel-aqi.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
<html>
<head>
<meta charset="utf-8">
<script src="./esl.js"></script>
<script src="./config.js"></script>
<link rel="stylesheet" href="./reset.css">
</head>
<body>
<style>
body {
/*background: #000;*/
}
</style>
<div id="main"></div>
<script>
// Schema:
// date,AQIindex,PM2.5,PM10,CO,NO2,SO2
var schema = [
{name: 'date', index: 0, text: '日期'},
{name: 'AQIindex', index: 1, text: 'AQI指数'},
{name: 'PM25', index: 2, text: 'PM2.5'},
{name: 'PM10', index: 3, text: 'PM10'},
{name: 'CO', index: 4, text: '一氧化碳 (CO)'},
{name: 'NO2', index: 5, text: '二氧化氮 (NO2)'},
{name: 'SO2', index: 6, text: '二氧化硫 (SO2)'},
{name: '等级', index: 7, text: '等级'}
];
require([
'data/aqi/BJdata',
'data/aqi/GZdata',
'data/aqi/SHdata',
'zrender/core/util',
'echarts',
'echarts/chart/parallel',
'echarts/component/legend',
'echarts/component/visualMap',
'echarts/component/parallel',
], function (dataBJ, dataGZ, dataSH, zrUtil, echarts) {
var chart = echarts.init(document.getElementById('main'));
var lineStyle = {
normal: {
width: 1
// opacity: 0.5,
// shadowBlur: 10,
// shadowOffsetX: 0,
// shadowOffsetY: 0,
// shadowColor: 'rgba(0, 0, 0, 0.5)'
}
};
chart.setOption({
legend: {
bottom: 30,
data: ['北京', '上海', '广州'],
itemGap: 20,
textStyle: {
// color: '#fff',
fontSize: 16
}
},
tooltip: {
padding: 10,
backgroundColor: '#222',
borderColor: '#777',
borderWidth: 1,
formatter: function (obj) {
var value = obj[0].value;
return '<div style="border-bottom: 1px solid rgba(255,255,255,.3); font-size: 18px;padding-bottom: 7px;margin-bottom: 7px">'
+ obj[0].seriesName + ' ' + value[0] + '日期:'
+ value[7]
+ '</div>'
+ schema[1].text + ':' + value[1] + '<br>'
+ schema[2].text + ':' + value[2] + '<br>'
+ schema[3].text + ':' + value[3] + '<br>'
+ schema[4].text + ':' + value[4] + '<br>'
+ schema[5].text + ':' + value[5] + '<br>'
+ schema[6].text + ':' + value[6] + '<br>';
}
},
visualMap: {
show: true,
min: 0,
max: 150,
dimension: 2,
inRange: {
color: ['#d94e5d','#eac736','#50a3ba'].reverse(),
// colorAlpha: [0, 1]
}
},
// dataZoom: {
// show: true,
// orient: 'vertical',
// parallelAxisIndex: [0]
// },
parallelAxis: [
{dim: 0, name: schema[0].text, inverse: true, max: 31, nameLocation: 'start'},
{dim: 1, name: schema[1].text},
{dim: 2, name: schema[2].text},
{dim: 3, name: schema[3].text},
{dim: 4, name: schema[4].text},
{dim: 5, name: schema[5].text},
{dim: 6, name: schema[6].text},
{dim: 7, name: schema[7].text,
type: 'category', data: ['优', '良', '轻度污染', '中度污染', '重度污染', '严重污染']}
],
parallel: {
bottom: 100,
parallelAxisDefault: {
type: 'value',
name: 'AQI指数',
nameLocation: 'end',
nameGap: 20,
nameTextStyle: {
// color: '#fff',
fontSize: 14
},
axisLine: {
lineStyle: {
// color: '#aaa'
}
},
axisTick: {
lineStyle: {
// color: '#777'
}
},
splitLine: {
show: false
},
axisLabel: {
textStyle: {
// color: '#fff'
}
}
}
},
series: [
{
name: '北京',
type: 'parallel',
lineStyle: lineStyle,
data: dataBJ
// data: [
// [ 1, 32,12 , 19, 28,1.39,24, 8,"优"],
// ]
},
{
name: '上海',
type: 'parallel',
lineStyle: lineStyle,
data: dataSH
// data: [
// [ 1, 332,212 , 119, 128,12.39,124, 18,"良"],
// ]
},
{
name: '广州',
type: 'parallel',
lineStyle: lineStyle,
data: dataGZ
}
]
});
});
</script>
</body>
</html>