diff --git a/src/component/marker/MarkAreaView.ts b/src/component/marker/MarkAreaView.ts index e3483453c4..f68653f447 100644 --- a/src/component/marker/MarkAreaView.ts +++ b/src/component/marker/MarkAreaView.ts @@ -412,12 +412,12 @@ function createList( const data = seriesModel.getData(); const info = data.getDimensionInfo( data.mapDimension(coordDim) - ) || {}; + ) || {} as SeriesDimensionDefine; // In map series data don't have lng and lat dimension. Fallback to same with coordSys return extend(extend({}, info), { name: coordDim, // DON'T use ordinalMeta to parse and collect ordinal. - ordinalMeta: null + ordinalMeta: null, }); }); dataDims = map(dims, (dim, idx) => ({ diff --git a/src/component/marker/MarkLineView.ts b/src/component/marker/MarkLineView.ts index 68c048b4df..9ee9aa43d0 100644 --- a/src/component/marker/MarkLineView.ts +++ b/src/component/marker/MarkLineView.ts @@ -443,14 +443,15 @@ function createList(coordSys: CoordinateSystem, seriesModel: SeriesModel, mlMode let coordDimsInfos: SeriesDimensionDefine[]; if (coordSys) { coordDimsInfos = map(coordSys && coordSys.dimensions, function (coordDim) { - const info = seriesModel.getData().getDimensionInfo( - seriesModel.getData().mapDimension(coordDim) - ) || {}; + const data = seriesModel.getData(); + const info = data.getDimensionInfo( + data.mapDimension(coordDim) + ) || {} as SeriesDimensionDefine; // In map series data don't have lng and lat dimension. Fallback to same with coordSys return extend(extend({}, info), { name: coordDim, // DON'T use ordinalMeta to parse and collect ordinal. - ordinalMeta: null + ordinalMeta: null, }); }); } diff --git a/src/component/marker/MarkPointView.ts b/src/component/marker/MarkPointView.ts index bad3d19a07..6f22205ff5 100644 --- a/src/component/marker/MarkPointView.ts +++ b/src/component/marker/MarkPointView.ts @@ -203,14 +203,15 @@ function createData( let coordDimsInfos: SeriesDimensionDefine[]; if (coordSys) { coordDimsInfos = map(coordSys && coordSys.dimensions, function (coordDim) { - const info = seriesModel.getData().getDimensionInfo( - seriesModel.getData().mapDimension(coordDim) - ) || {}; + const data = seriesModel.getData(); + const info = data.getDimensionInfo( + data.mapDimension(coordDim) + ) || {} as SeriesDimensionDefine; // In map series data don't have lng and lat dimension. Fallback to same with coordSys return extend(extend({}, info), { name: coordDim, // DON'T use ordinalMeta to parse and collect ordinal. - ordinalMeta: null + ordinalMeta: null, }); }); } diff --git a/src/data/SeriesData.ts b/src/data/SeriesData.ts index 472d3b3c7e..4e0663227b 100644 --- a/src/data/SeriesData.ts +++ b/src/data/SeriesData.ts @@ -317,23 +317,19 @@ class SeriesData< invertedIndicesMap[dimensionName] = []; } - let dimIdx = i; - if (zrUtil.isNumber(dimensionInfo.storeDimIndex)) { - dimIdx = dimensionInfo.storeDimIndex; - } - if (otherDims.itemName === 0) { - this._nameDimIdx = dimIdx; - } - if (otherDims.itemId === 0) { - this._idDimIdx = dimIdx; - } - if (__DEV__) { zrUtil.assert(assignStoreDimIdx || dimensionInfo.storeDimIndex >= 0); } if (assignStoreDimIdx) { dimensionInfo.storeDimIndex = i; } + + if (otherDims.itemName === 0) { + this._nameDimIdx = dimensionInfo.storeDimIndex; + } + if (otherDims.itemId === 0) { + this._idDimIdx = dimensionInfo.storeDimIndex; + } } this.dimensions = dimensionNames; diff --git a/src/data/SeriesDimensionDefine.ts b/src/data/SeriesDimensionDefine.ts index 3d4b628f21..1ce09813a0 100644 --- a/src/data/SeriesDimensionDefine.ts +++ b/src/data/SeriesDimensionDefine.ts @@ -69,9 +69,25 @@ class SeriesDimensionDefine { /** * The index of this dimension in `series.encode[coordDim]`. * Mandatory. + * + * For example, + * Suppose + * - encode option: + * ```js + * encode: { + * x: [1, 3, 5], + * y: [0, 2], + * } + * ``` + * - This `seriesDimensionDefine` corresponds to series dimension index `3`, + * - `coordDim` is `x` + * Then + * coordDimIndex should be `1`, where `encode[coordDim][coordDimIndex] === 3` */ coordDimIndex?: number; + /** + * The term "other" means "other than coord". * The format of `otherDims` is: * ```js * { diff --git a/src/data/helper/createDimensions.ts b/src/data/helper/createDimensions.ts index d480e43da7..b8f8e8a9ef 100644 --- a/src/data/helper/createDimensions.ts +++ b/src/data/helper/createDimensions.ts @@ -253,7 +253,11 @@ export default function prepareSeriesDataSchema( }); }); - function applyDim(resultItem: SeriesDimensionDefine, coordDim: DimensionName, coordDimIndex: DimensionIndex) { + function applyDim( + resultItem: SeriesDimensionDefine, + coordDim: SeriesDimensionDefine['coordDim'], + coordDimIndex: SeriesDimensionDefine['coordDimIndex'] + ): void { if (VISUAL_DIMENSIONS.get(coordDim as keyof DataVisualDimensions) != null) { resultItem.otherDims[coordDim as keyof DataVisualDimensions] = coordDimIndex; } diff --git a/test/marker-dataset-encode.html b/test/marker-dataset-encode.html new file mode 100644 index 0000000000..1d7292ebc4 --- /dev/null +++ b/test/marker-dataset-encode.html @@ -0,0 +1,283 @@ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + diff --git a/test/series-omitUnusedDimensions.html b/test/series-omitUnusedDimensions.html index 7fdf898517..2972022083 100644 --- a/test/series-omitUnusedDimensions.html +++ b/test/series-omitUnusedDimensions.html @@ -210,7 +210,9 @@ }; var chart = testHelper.create(echarts, 'main0', { - title: 'Omit unused dimension: **series index should be matched**', + title: [ + 'Omit unused dimension: **series index should be matched** (tooltip should display x axis name)' + ], option: option }); });