Skip to content

Commit

Permalink
perf: 优化 customTree 包含大量 values 生成结构时性能
Browse files Browse the repository at this point in the history
  • Loading branch information
wjgogogo committed Dec 11, 2023
1 parent 6e3683b commit a4baf65
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 7 additions & 0 deletions packages/s2-core/src/data-set/custom-tree-pivot-data-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,11 @@ export class CustomTreePivotDataSet extends PivotDataSet {
},
};
}

getValues() {
// 交叉模式下,values 会被传入用于生成 pivotMeta 结构
// 在 customTree 模式下, customTree 对应的 rows 只包含 extra,不需要像交叉模式那样从 一行数据里面获取对应 values 然后生成一对多的结构
// 所以传入一个空的 values 结构即可
return [];
}
}
9 changes: 7 additions & 2 deletions packages/s2-core/src/data-set/pivot-data-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ export class PivotDataSet extends BaseDataSet {
this.rowPivotMeta = new Map();
this.colPivotMeta = new Map();
DebuggerUtil.getInstance().debugCallback(DEBUG_TRANSFORM_DATA, () => {
const { rows, columns, values, valueInCols } = this.fields;
const { rows, columns, valueInCols } = this.fields;
const { indexesData } = transformIndexesData({
rows,
columns: columns as string[],
values,
values: this.getValues(),
valueInCols,
data: this.originData.concat(this.totalData),
indexesData: this.indexesData,
Expand All @@ -106,6 +106,11 @@ export class PivotDataSet extends BaseDataSet {
this.handleDimensionValuesSort();
}

getValues() {
const { values } = this.fields;
return values;
}

/**
* Provide a way to append some drill-down data in indexesData
* @param extraRowField
Expand Down

0 comments on commit a4baf65

Please sign in to comment.