Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复维度字段中包含 [&] 分隔符导致的获取数据不正确的问题 #2488

Merged
merged 2 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));
wjgogogo marked this conversation as resolved.
Show resolved Hide resolved
return metaValues.map((v) => v.dimensions);
}

export function getFlattenDimensionValues(
Expand Down
Loading