Skip to content

Commit 59f3f9a

Browse files
authored
Merge pull request #21439 from apache/fix/marker-dataset
fix(marker): fix marker fails to render with dataset and encode
2 parents f903bf2 + 4d3fff8 commit 59f3f9a

File tree

8 files changed

+326
-23
lines changed

8 files changed

+326
-23
lines changed

src/component/marker/MarkAreaView.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,12 +412,12 @@ function createList(
412412
const data = seriesModel.getData();
413413
const info = data.getDimensionInfo(
414414
data.mapDimension(coordDim)
415-
) || {};
415+
) || {} as SeriesDimensionDefine;
416416
// In map series data don't have lng and lat dimension. Fallback to same with coordSys
417417
return extend(extend({}, info), {
418418
name: coordDim,
419419
// DON'T use ordinalMeta to parse and collect ordinal.
420-
ordinalMeta: null
420+
ordinalMeta: null,
421421
});
422422
});
423423
dataDims = map(dims, (dim, idx) => ({

src/component/marker/MarkLineView.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,14 +443,15 @@ function createList(coordSys: CoordinateSystem, seriesModel: SeriesModel, mlMode
443443
let coordDimsInfos: SeriesDimensionDefine[];
444444
if (coordSys) {
445445
coordDimsInfos = map(coordSys && coordSys.dimensions, function (coordDim) {
446-
const info = seriesModel.getData().getDimensionInfo(
447-
seriesModel.getData().mapDimension(coordDim)
448-
) || {};
446+
const data = seriesModel.getData();
447+
const info = data.getDimensionInfo(
448+
data.mapDimension(coordDim)
449+
) || {} as SeriesDimensionDefine;
449450
// In map series data don't have lng and lat dimension. Fallback to same with coordSys
450451
return extend(extend({}, info), {
451452
name: coordDim,
452453
// DON'T use ordinalMeta to parse and collect ordinal.
453-
ordinalMeta: null
454+
ordinalMeta: null,
454455
});
455456
});
456457
}

src/component/marker/MarkPointView.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,15 @@ function createData(
203203
let coordDimsInfos: SeriesDimensionDefine[];
204204
if (coordSys) {
205205
coordDimsInfos = map(coordSys && coordSys.dimensions, function (coordDim) {
206-
const info = seriesModel.getData().getDimensionInfo(
207-
seriesModel.getData().mapDimension(coordDim)
208-
) || {};
206+
const data = seriesModel.getData();
207+
const info = data.getDimensionInfo(
208+
data.mapDimension(coordDim)
209+
) || {} as SeriesDimensionDefine;
209210
// In map series data don't have lng and lat dimension. Fallback to same with coordSys
210211
return extend(extend({}, info), {
211212
name: coordDim,
212213
// DON'T use ordinalMeta to parse and collect ordinal.
213-
ordinalMeta: null
214+
ordinalMeta: null,
214215
});
215216
});
216217
}

src/data/SeriesData.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -317,23 +317,19 @@ class SeriesData<
317317
invertedIndicesMap[dimensionName] = [];
318318
}
319319

320-
let dimIdx = i;
321-
if (zrUtil.isNumber(dimensionInfo.storeDimIndex)) {
322-
dimIdx = dimensionInfo.storeDimIndex;
323-
}
324-
if (otherDims.itemName === 0) {
325-
this._nameDimIdx = dimIdx;
326-
}
327-
if (otherDims.itemId === 0) {
328-
this._idDimIdx = dimIdx;
329-
}
330-
331320
if (__DEV__) {
332321
zrUtil.assert(assignStoreDimIdx || dimensionInfo.storeDimIndex >= 0);
333322
}
334323
if (assignStoreDimIdx) {
335324
dimensionInfo.storeDimIndex = i;
336325
}
326+
327+
if (otherDims.itemName === 0) {
328+
this._nameDimIdx = dimensionInfo.storeDimIndex;
329+
}
330+
if (otherDims.itemId === 0) {
331+
this._idDimIdx = dimensionInfo.storeDimIndex;
332+
}
337333
}
338334

339335
this.dimensions = dimensionNames;

src/data/SeriesDimensionDefine.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,25 @@ class SeriesDimensionDefine {
6969
/**
7070
* The index of this dimension in `series.encode[coordDim]`.
7171
* Mandatory.
72+
*
73+
* For example,
74+
* Suppose
75+
* - encode option:
76+
* ```js
77+
* encode: {
78+
* x: [1, 3, 5],
79+
* y: [0, 2],
80+
* }
81+
* ```
82+
* - This `seriesDimensionDefine` corresponds to series dimension index `3`,
83+
* - `coordDim` is `x`
84+
* Then
85+
* coordDimIndex should be `1`, where `encode[coordDim][coordDimIndex] === 3`
7286
*/
7387
coordDimIndex?: number;
88+
7489
/**
90+
* The term "other" means "other than coord".
7591
* The format of `otherDims` is:
7692
* ```js
7793
* {

src/data/helper/createDimensions.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,11 @@ export default function prepareSeriesDataSchema(
253253
});
254254
});
255255

256-
function applyDim(resultItem: SeriesDimensionDefine, coordDim: DimensionName, coordDimIndex: DimensionIndex) {
256+
function applyDim(
257+
resultItem: SeriesDimensionDefine,
258+
coordDim: SeriesDimensionDefine['coordDim'],
259+
coordDimIndex: SeriesDimensionDefine['coordDimIndex']
260+
): void {
257261
if (VISUAL_DIMENSIONS.get(coordDim as keyof DataVisualDimensions) != null) {
258262
resultItem.otherDims[coordDim as keyof DataVisualDimensions] = coordDimIndex;
259263
}

0 commit comments

Comments
 (0)