Skip to content

Commit c9fd23f

Browse files
committed
tweak
1 parent 3e9f239 commit c9fd23f

File tree

4 files changed

+212
-8
lines changed

4 files changed

+212
-8
lines changed

src/component/dataZoom/AxisProxy.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ define(function(require) {
136136
var foundOtherAxisModel;
137137
ecModel.eachComponent(otherAxisDim + 'Axis', function (otherAxisModel) {
138138
if ((otherAxisModel.get(coordSysIndexName) || 0)
139-
=== (axisModel.get(coordSysIndexName) || 0)) {
139+
=== (axisModel.get(coordSysIndexName) || 0)
140+
) {
140141
foundOtherAxisModel = otherAxisModel;
141142
}
142143
});
@@ -196,21 +197,25 @@ define(function(require) {
196197

197198
// FIXME
198199
// Toolbox may has dataZoom injected. And if there are stacked bar chart
199-
// with NaN data. NaN will be filtered and stack will be wrong.
200-
// So we need to force the mode to be set empty
200+
// with NaN data, NaN will be filtered and stack will be wrong.
201+
// So we need to force the mode to be set empty.
202+
// In fect, it is not a big deal that do not support filterMode-'filter'
203+
// when using toolbox#dataZoom, utill tooltip#dataZoom support "single axis
204+
// selection" some day, which might need "adapt to data extent on the
205+
// otherAxis", which is disabled by filterMode-'empty'.
201206
var otherAxisModel = this.getOtherAxisModel();
202207
if (dataZoomModel.get('$fromToolbox')
203-
&& otherAxisModel && otherAxisModel.get('type') === 'category') {
208+
&& otherAxisModel
209+
&& otherAxisModel.get('type') === 'category'
210+
) {
204211
filterMode = 'empty';
205212
}
213+
206214
// Process series data
207215
each(seriesModels, function (seriesModel) {
208216
var seriesData = seriesModel.getData();
209-
if (!seriesData) {
210-
return;
211-
}
212217

213-
each(seriesModel.coordDimToDataDim(axisDim), function (dim) {
218+
seriesData && each(seriesModel.coordDimToDataDim(axisDim), function (dim) {
214219
if (filterMode === 'empty') {
215220
seriesModel.setData(
216221
seriesData.map(dim, function (value) {

src/component/dataZoom/dataZoomProcessor.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ define(function (require) {
3636
var axisProxy = dataZoomModel.findRepresentativeAxisProxy();
3737
var percentRange = axisProxy.getDataPercentWindow();
3838
var valueRange = axisProxy.getDataValueWindow();
39+
3940
dataZoomModel.setRawRange({
4041
start: percentRange[0],
4142
end: percentRange[1],

test/dataZoom-scatter-category.html

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
<html>
2+
<head>
3+
<meta charset="utf-8">
4+
<script src="esl.js"></script>
5+
<script src="config.js"></script>
6+
<meta name="viewport" content="width=device-width, initial-scale=1" />
7+
</head>
8+
<body>
9+
<style>
10+
html, body, #main {
11+
margin: 0;
12+
padding: 0;
13+
width: 100%;
14+
height: 100%;
15+
}
16+
</style>
17+
<div id="main"></div>
18+
<script>
19+
20+
21+
require([
22+
'echarts',
23+
'echarts/chart/scatter',
24+
'echarts/component/legend',
25+
'echarts/component/grid',
26+
'echarts/component/tooltip',
27+
'echarts/component/toolbox',
28+
'echarts/component/dataZoom'
29+
], function (echarts) {
30+
31+
chart = echarts.init(document.getElementById('main'), null, {
32+
renderer: 'canvas'
33+
});
34+
35+
var data1 = [];
36+
var data2 = [];
37+
var data3 = [];
38+
var xAxisData = [];
39+
var yAxisData = [];
40+
41+
var random = function (max) {
42+
return (Math.random() * max).toFixed(3);
43+
};
44+
45+
for (var i = 0; i <= 10; i++) {
46+
xAxisData.push(i + '');
47+
}
48+
49+
for (var i = 0; i <= 30; i++) {
50+
yAxisData.push(i + '');
51+
}
52+
53+
for (var i = 0; i < 30; i++) {
54+
data1.push([
55+
Math.round(random(10)),
56+
Math.round(random(30))//,
57+
// Math.round(random(100))
58+
]);
59+
data2.push([
60+
Math.round(random(10)),
61+
Math.round(random(30))//,
62+
// Math.round(random(100))
63+
]);
64+
data3.push([
65+
Math.round(random(10)),
66+
Math.round(random(30))//,
67+
// Math.round(random(100))
68+
]);
69+
}
70+
71+
chart.setOption({
72+
legend: {
73+
data: ['scatter', 'scatter2', 'scatter3']
74+
},
75+
toolbox: {
76+
// y: 'bottom',
77+
feature: {
78+
dataView: {},
79+
dataZoom: {
80+
show: true,
81+
yAxisIndex: false
82+
},
83+
restore: {show: true},
84+
saveAsImage: {}
85+
}
86+
},
87+
tooltip: {
88+
},
89+
dataZoom: [
90+
{
91+
show: true,
92+
xAxisIndex: [0],
93+
// If set to 'filter', y axis will be effected by x dataZoom
94+
filterMode: 'empty',
95+
start: 0,
96+
end: 100
97+
},
98+
{
99+
show: true,
100+
yAxisIndex: [0],
101+
filterMode: 'empty',
102+
start: 0,
103+
end: 20
104+
},
105+
{
106+
type: 'inside',
107+
xAxisIndex: [0],
108+
filterMode: 'empty',
109+
start: 0,
110+
end: 100
111+
},
112+
{
113+
type: 'inside',
114+
yAxisIndex: [0],
115+
filterMode: 'empty',
116+
start: 0,
117+
end: 20
118+
}
119+
],
120+
xAxis: {
121+
type: 'category',
122+
splitLine: {
123+
show: true
124+
},
125+
data: xAxisData
126+
},
127+
yAxis: {
128+
type: 'category',
129+
splitLine: {
130+
show: true
131+
},
132+
data: yAxisData
133+
},
134+
series: [
135+
{
136+
name: 'scatter',
137+
type: 'scatter',
138+
itemStyle: {
139+
normal: {
140+
opacity: 0.8,
141+
// shadowBlur: 10,
142+
// shadowOffsetX: 0,
143+
// shadowOffsetY: 0,
144+
// shadowColor: 'rgba(0, 0, 0, 0.5)'
145+
}
146+
},
147+
symbolSize: function (val) {
148+
return val[0] * 4;
149+
},
150+
data: data1
151+
},
152+
{
153+
name: 'scatter2',
154+
type: 'scatter',
155+
itemStyle: {
156+
normal: {
157+
opacity: 0.8
158+
}
159+
},
160+
symbolSize: function (val) {
161+
return val[0] * 4;
162+
},
163+
data: data2
164+
},
165+
{
166+
name: 'scatter3',
167+
type: 'scatter',
168+
itemStyle: {
169+
normal: {
170+
opacity: 0.8,
171+
}
172+
},
173+
symbolSize: function (val) {
174+
return val[0] * 4;
175+
},
176+
data: data3
177+
}
178+
]
179+
});
180+
// console.profileEnd('setOption');
181+
})
182+
183+
window.onresize = function () {
184+
chart.resize();
185+
};
186+
187+
</script>
188+
189+
<!-- // <script src="js/memory-stats.js"></script> -->
190+
<!-- // <script src="js/memory.js"></script> -->
191+
</body>
192+
</html>

test/graph-grid.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
'echarts/component/title',
2424
'echarts/component/legend',
2525
'echarts/component/tooltip',
26+
'echarts/component/toolbox',
2627
'zrender/vml/vml',
2728

2829
'theme/vintage'
@@ -52,6 +53,11 @@
5253
yAxis: {
5354
type : 'value'
5455
},
56+
toolbox: {
57+
feature: {
58+
dataZoom: {}
59+
}
60+
},
5561
series: [
5662
{
5763
type: 'graph',

0 commit comments

Comments
 (0)