Skip to content

Commit

Permalink
fix: 修复维度字段中包含 [&] 分隔符导致的获取数据不正确的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
wjgogogo committed Dec 20, 2023
1 parent 918e52e commit a9f907e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion packages/s2-core/src/data-set/interface.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -11,6 +11,8 @@ export type Query = Record<string, any>;
export type PivotMetaValue = {
// 当前维度结合父级维度生成的完整 id 信息
id: string;
// 当前维度结合父级维度生成的完整 dimensions 信息,主要是预防 field 数据本身出现 [&] 导致维度信息识别不正确
dimensions: string[];
// 当前维度
value: string;
level: number;
Expand Down
10 changes: 5 additions & 5 deletions packages/s2-core/src/utils/dataset/pivot-data-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -232,6 +231,7 @@ export function getDataPath(params: DataPathParams) {

currentMeta.set(value, {
id,
dimensions: currentDimensions,
value,
level,
children: new Map(),
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit a9f907e

Please sign in to comment.