-
Notifications
You must be signed in to change notification settings - Fork 0
/
markpoint_test.html
190 lines (176 loc) · 6.09 KB
/
markpoint_test.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<!-- 引入 ECharts 文件 -->
<script src="echarts.min.js"></script>
</head>
<body>
<!-- 为 ECharts 准备一个具备大小(宽高)的 DOM -->
<div id="main" style="width: 600px;height:400px;"></div>
<script type="text/javascript">
// 基于准备好的dom,初始化echarts实例
var chart = echarts.init(document.getElementById('main'));
var xAxisData = [];
var data1 = [];
var data2 = [];
for (var i = 0; i < 10; i++) {
xAxisData.push('类目' + i);
data1.push(+Math.random().toFixed(2));
data2.push(+Math.random().toFixed(2));
}
if (console && console.log) {
console.log(data1);
console.log(data2);
}
chart.setOption({
legend: {
data: ['line-stack', 'line2-stack', 'line3']
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'line'
}
},
xAxis: {
// data: ['类目1', '类目2', '类目3', '类目4', '类目5',]
data: xAxisData,
boundaryGap: false,
// inverse: true,
splitArea: {
show: true
}
},
yAxis: {
splitLine: {
// show: false
}
},
series: [
{
name: 'line-stack',
type: 'line',
stack: 'all',
symbolSize: 6,
areaStyle: { normal: {} },
data: data1,
markPoint: {
data: [
{
name: '最大值',
type: 'max',
value: 1
},
{
xAxis: '类目3',
yAxis: 0.5,
value: 2
}
]
}
},
{
name: 'line2-stack',
type: 'line',
stack: 'all',
symbolSize: 6,
areaStyle: { normal: {} },
data: data2,
markPoint: {
label: {
normal: {
formatter: function (param) {
return param.name + ' ' + param.value;
},
textStyle: {
color: '#000'
},
position: 'top'
}
},
data: [
{
name: '最小值stack',
type: 'min',
value: 1
},
{
name: '最大值stack',
type: 'max',
value: 1
},
{
name: '平均值stack',
type: 'average',
value: 1
}
]
}
},
{
name: 'line3',
type: 'line',
symbolSize: 6,
data: data2,
markPoint: {
label: {
normal: {
formatter: function (param) {
return param.name + ' ' + (param.value || '');
},
textStyle: {
color: '#000'
},
position: 'top'
}
},
data: [
{
name: '任意屏幕位置',
value: 111,
extData: { a: 1, b: 2 },
x: 50, y: 100
},
{
name: '000000000',
coord: ['类目2', 0.6],
value: 1
},
{
name: '最小值',
type: 'min',
value: 1
},
{
name: '最大值x',
type: 'max',
value: 1
},
{
name: '最大值y',
type: 'max',
valueIndex: 0,
value: 1
},
{
name: '平均值',
type: 'average',
value: 1
},
{
name: 'Y轴固定',
xAxis: 'max',
y: 100
}
]
}
}
]
});
chart.on('click', function (params) {
console.log(params, params.data);
});
</script>
</body>
</html>