From a4baf6556bb0a72f1bd13c46e2c6efca8a75004c Mon Sep 17 00:00:00 2001 From: wjgogogo <906626481@qq.com> Date: Mon, 11 Dec 2023 19:10:20 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=20customTree=20?= =?UTF-8?q?=E5=8C=85=E5=90=AB=E5=A4=A7=E9=87=8F=20values=20=E7=94=9F?= =?UTF-8?q?=E6=88=90=E7=BB=93=E6=9E=84=E6=97=B6=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../s2-core/src/data-set/custom-tree-pivot-data-set.ts | 7 +++++++ packages/s2-core/src/data-set/pivot-data-set.ts | 9 +++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/s2-core/src/data-set/custom-tree-pivot-data-set.ts b/packages/s2-core/src/data-set/custom-tree-pivot-data-set.ts index 8215d774d5..47952c1be3 100644 --- a/packages/s2-core/src/data-set/custom-tree-pivot-data-set.ts +++ b/packages/s2-core/src/data-set/custom-tree-pivot-data-set.ts @@ -54,4 +54,11 @@ export class CustomTreePivotDataSet extends PivotDataSet { }, }; } + + getValues() { + // 交叉模式下,values 会被传入用于生成 pivotMeta 结构 + // 在 customTree 模式下, customTree 对应的 rows 只包含 extra,不需要像交叉模式那样从 一行数据里面获取对应 values 然后生成一对多的结构 + // 所以传入一个空的 values 结构即可 + return []; + } } diff --git a/packages/s2-core/src/data-set/pivot-data-set.ts b/packages/s2-core/src/data-set/pivot-data-set.ts index 99dd3975c6..dadd06de19 100644 --- a/packages/s2-core/src/data-set/pivot-data-set.ts +++ b/packages/s2-core/src/data-set/pivot-data-set.ts @@ -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, @@ -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