From a9f907e4b9f4e29eaf0137389177c6ce62b4bbae Mon Sep 17 00:00:00 2001 From: wjgogogo <906626481@qq.com> Date: Wed, 20 Dec 2023 19:51:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=BB=B4=E5=BA=A6?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E4=B8=AD=E5=8C=85=E5=90=AB=20[&]=20=E5=88=86?= =?UTF-8?q?=E9=9A=94=E7=AC=A6=E5=AF=BC=E8=87=B4=E7=9A=84=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=B8=8D=E6=AD=A3=E7=A1=AE=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/s2-core/src/data-set/interface.ts | 4 +++- packages/s2-core/src/utils/dataset/pivot-data-set.ts | 10 +++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/s2-core/src/data-set/interface.ts b/packages/s2-core/src/data-set/interface.ts index 7d8c8ab1c3..5cab0f105f 100644 --- a/packages/s2-core/src/data-set/interface.ts +++ b/packages/s2-core/src/data-set/interface.ts @@ -1,5 +1,5 @@ import type { QueryDataType } from '../common/constant/query'; -import type { Data, SortParam } from '../common/interface'; +import type { SortParam } from '../common/interface'; import type { Node } from '../facet/layout/node'; import type { BaseDataSet } from './base-data-set'; @@ -11,6 +11,8 @@ export type Query = Record; export type PivotMetaValue = { // 当前维度结合父级维度生成的完整 id 信息 id: string; + // 当前维度结合父级维度生成的完整 dimensions 信息,主要是预防 field 数据本身出现 [&] 导致维度信息识别不正确 + dimensions: string[]; // 当前维度 value: string; level: number; diff --git a/packages/s2-core/src/utils/dataset/pivot-data-set.ts b/packages/s2-core/src/utils/dataset/pivot-data-set.ts index 077eb3a9aa..8e73baa460 100644 --- a/packages/s2-core/src/utils/dataset/pivot-data-set.ts +++ b/packages/s2-core/src/utils/dataset/pivot-data-set.ts @@ -214,11 +214,10 @@ export function getDataPath(params: DataPathParams) { const value = dimensionValues[i]; if (isFirstCreate && currentMeta && !currentMeta?.has(value)) { - const id = dimensionValues + const currentDimensions = dimensionValues .slice(0, i + 1) - .map((it) => String(it)) - .join(ID_SEPARATOR); - + .map((it) => String(it)); + const id = currentDimensions.join(ID_SEPARATOR); const isTotal = value === TOTAL_VALUE; let level; @@ -232,6 +231,7 @@ export function getDataPath(params: DataPathParams) { currentMeta.set(value, { id, + dimensions: currentDimensions, value, level, children: new Map(), @@ -536,7 +536,7 @@ export function flattenDimensionValues(params: { sortedDimensionValues, }); - return metaValues.map((v) => v.id.split(ID_SEPARATOR)); + return metaValues.map((v) => v.dimensions); } export function getFlattenDimensionValues(