diff --git a/src/component/dataZoom/SliderZoomView.js b/src/component/dataZoom/SliderZoomView.js index 62af7611473978b2747f3f139c951661925eb57a..e09c001c573aed2e903f7b67ccdef6bc796dce66 100644 --- a/src/component/dataZoom/SliderZoomView.js +++ b/src/component/dataZoom/SliderZoomView.js @@ -397,10 +397,13 @@ var SliderZoomView = DataZoomView.extend({ var otherDim = getOtherDim(dimNames.name); var otherAxisInverse; var coordSys = seriesModel.coordinateSystem; + if (otherDim != null && coordSys.getOtherAxis) { otherAxisInverse = coordSys.getOtherAxis(thisAxis).inverse; } + otherDim = seriesModel.coordDimToDataDim(otherDim)[0]; + result = { thisAxis: thisAxis, series: seriesModel, diff --git a/src/data/List.js b/src/data/List.js index 1c558824d5430ba5f2a72438262412eedc53d12a..bc03ee9718af0b8bc5a6f80da7e9f811be9ad0e9 100644 --- a/src/data/List.js +++ b/src/data/List.js @@ -595,10 +595,14 @@ listProto.get = function (dim, idx, stack) { if (idx < 0 || idx >= this._count) { return NaN; } + var storage = this._storage; + if (!storage[dim]) { + // TODO Warn ? + return NaN; + } idx = this.getRawIndex(idx); - var storage = this._storage; var chunkIndex = Math.floor(idx / this._chunkSize); var chunkOffset = idx % this._chunkSize; @@ -957,6 +961,14 @@ function normalizeDimensions(dimensions) { return dimensions; } +function validateDimensions(list, dims) { + for (var i = 0; i < dims.length; i++) { + if (!list._storage[dims[i]]) { + console.error('Unkown dimension ' + dims[i]); + } + } +} + /** * Data iteration * @param {string|Array.} @@ -970,6 +982,8 @@ function normalizeDimensions(dimensions) { * list.each(function (idx) {}) */ listProto.each = function (dims, cb, stack, context) { + 'use strict'; + if (typeof dims === 'function') { context = stack; stack = cb; @@ -979,6 +993,10 @@ listProto.each = function (dims, cb, stack, context) { dims = zrUtil.map(normalizeDimensions(dims), this.getDimension, this); + if (__DEV__) { + validateDimensions(this, dims); + } + var dimSize = dims.length; context = context || this; @@ -1032,6 +1050,11 @@ listProto.filterSelf = function (dimensions, cb, stack, context) { normalizeDimensions(dimensions), this.getDimension, this ); + if (__DEV__) { + validateDimensions(this, dimensions); + } + + var count = this.count(); var Ctor = getIndicesCtor(count); var newIndices = new Ctor(count); @@ -1091,6 +1114,11 @@ listProto.selectRange = function (range, stack) { dimensions.push(dim); } } + + if (__DEV__) { + validateDimensions(this, dimensions); + } + var dimSize = dimensions.length; if (!dimSize) { return; @@ -1154,6 +1182,8 @@ listProto.selectRange = function (range, stack) { * @return {Array} */ listProto.mapArray = function (dimensions, cb, stack, context) { + 'use strict'; + if (typeof dimensions === 'function') { context = stack; stack = cb; @@ -1161,6 +1191,10 @@ listProto.mapArray = function (dimensions, cb, stack, context) { dimensions = []; } + if (__DEV__) { + validateDimensions(this, dimensions); + } + var result = []; this.each(dimensions, function () { result.push(cb && cb.apply(this, arguments)); @@ -1208,10 +1242,16 @@ function cloneDimStore(originalDimStore) { * @return {Array} */ listProto.map = function (dimensions, cb, stack, context) { + 'use strict'; + dimensions = zrUtil.map( normalizeDimensions(dimensions), this.getDimension, this ); + if (__DEV__) { + validateDimensions(this, dimensions); + } + var list = cloneListForMapAndSample(this, dimensions); // Following properties are all immutable.