Skip to content

Commit a7e8aea

Browse files
committed
Tweak target series getter for visualMap, collection target series each time.
Otherwise, setOption at the second time will get wrong target series if it not specified.
1 parent afe3b07 commit a7e8aea

File tree

4 files changed

+17
-18
lines changed

4 files changed

+17
-18
lines changed

src/component/visualMap/ContinuousModel.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ define(function(require) {
3939
optionUpdated: function (newOption, isInit) {
4040
ContinuousModel.superApply(this, 'optionUpdated', arguments);
4141

42-
this.resetTargetSeries();
4342
this.resetExtent();
4443

4544
this.resetVisual(function (mappingOption) {

src/component/visualMap/PiecewiseModel.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ define(function(require) {
8181
*/
8282
this._pieceList = [];
8383

84-
this.resetTargetSeries();
8584
this.resetExtent();
8685

8786
/**

src/component/visualMap/VisualMapModel.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ define(function(require) {
6464
zlevel: 0,
6565
z: 4,
6666

67-
seriesIndex: null, // 所控制的series indices,默认所有有value的series.
67+
seriesIndex: 'all', // 'all' or null/undefined: all series.
68+
// A number or an array of number: the specified series.
6869

6970
// set min: 0, max: 200, only for campatible with ec2.
7071
// In fact min max should not have default value.
@@ -181,26 +182,31 @@ define(function(require) {
181182
);
182183
},
183184

184-
185185
/**
186186
* @protected
187+
* @return {Array.<number>} An array of series indices.
187188
*/
188-
resetTargetSeries: function () {
189-
var thisOption = this.option;
190-
var allSeriesIndex = thisOption.seriesIndex == null;
191-
thisOption.seriesIndex = allSeriesIndex
192-
? [] : modelUtil.normalizeToArray(thisOption.seriesIndex);
189+
getTargetSeriesIndices: function () {
190+
var optionSeriesIndex = this.option.seriesIndex;
191+
var seriesIndices = [];
192+
193+
if (optionSeriesIndex == null || optionSeriesIndex === 'all') {
194+
this.ecModel.eachSeries(function (seriesModel, index) {
195+
seriesIndices.push(index);
196+
});
197+
}
198+
else {
199+
seriesIndices = modelUtil.normalizeToArray(optionSeriesIndex);
200+
}
193201

194-
allSeriesIndex && this.ecModel.eachSeries(function (seriesModel, index) {
195-
thisOption.seriesIndex.push(index);
196-
});
202+
return seriesIndices;
197203
},
198204

199205
/**
200206
* @public
201207
*/
202208
eachTargetSeries: function (callback, context) {
203-
zrUtil.each(this.option.seriesIndex, function (seriesIndex) {
209+
zrUtil.each(this.getTargetSeriesIndices(), function (seriesIndex) {
204210
callback.call(context, this.ecModel.getSeriesByIndex(seriesIndex));
205211
}, this);
206212
},

test/bar.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@
2424
}
2525
</style>
2626

27-
<h1>
28-
<input type="button" onclick="testHelper.setURLParam(['cn', 'en'], 'cn')" value="CN"/>
29-
<input type="button" onclick="testHelper.setURLParam(['cn', 'en'], 'en')" value="EN"/>
30-
</h1>
31-
3227
<div id="main" class="chart"></div>
3328
<script>
3429

0 commit comments

Comments
 (0)