Skip to content

Commit 662f14e

Browse files
committed
fix(line): correctly stack not-synced time series data. close #15742
1 parent 8bd6f0b commit 662f14e

File tree

3 files changed

+130
-2
lines changed

3 files changed

+130
-2
lines changed

src/data/SeriesData.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1391,7 +1391,7 @@ class SeriesData<
13911391
const invertedIndicesMap = data._invertedIndicesMap;
13921392
zrUtil.each(invertedIndicesMap, function (invertedIndices, dim) {
13931393
const dimInfo = data._dimInfos[dim];
1394-
// Currently, only dimensions that has ordinalMeta can create inverted indices.
1394+
// Currently, only dimensions that have ordinalMeta or are of type time can create inverted indices.
13951395
const ordinalMeta = dimInfo.ordinalMeta;
13961396
const store = data._store;
13971397
if (ordinalMeta) {
@@ -1408,6 +1408,13 @@ class SeriesData<
14081408
invertedIndices[store.get(dimInfo.storeDimIndex, i) as number] = i;
14091409
}
14101410
}
1411+
else if (dimInfo.type === 'time') {
1412+
invertedIndices = invertedIndicesMap[dim] = { length: store.count() };
1413+
for (let i = 0; i < store.count(); i++) {
1414+
// Only support the case that all values are distinct.
1415+
invertedIndices[store.get(dimInfo.storeDimIndex, i) as number] = i;
1416+
}
1417+
}
14111418
});
14121419
};
14131420

src/data/helper/dataStackHelper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export function enableDataStack(
103103

104104
if (mayStack && !dimensionInfo.isExtraCoord) {
105105
// Find the first ordinal dimension as the stackedByDimInfo.
106-
if (!byIndex && !stackedByDimInfo && dimensionInfo.ordinalMeta) {
106+
if (!byIndex && !stackedByDimInfo && (dimensionInfo.ordinalMeta || dimensionInfo.type === 'time')) {
107107
stackedByDimInfo = dimensionInfo;
108108
}
109109
// Find the first stackable dimension as the stackedDimInfo.

test/line-stack-disjunct-timeseries.html

Lines changed: 121 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)