Skip to content

Commit d112448

Browse files
authored
Merge pull request #4765 from VisActor/refactor/dimension-null-empty-distinction
Refactor/dimension null empty distinction
2 parents 9ad0e54 + ef14971 commit d112448

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"comment": "fix: distinguish null and empty string values in row/column dimensions\n\n",
5+
"type": "none",
6+
"packageName": "@visactor/vtable"
7+
}
8+
],
9+
"packageName": "@visactor/vtable",
10+
"email": "gongshiwei@kkgroup.cn"
11+
}

packages/vtable/src/dataset/dataset.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -803,8 +803,9 @@ export class Dataset {
803803
if (this.indicatorsAsCol) {
804804
assignedIndicatorKey_value = colKeys[col_j].indicatorKey;
805805
}
806-
const flatRowKey = rowKey.join(this.stringJoinChar);
807-
const flatColKey = colKey.join(this.stringJoinChar);
806+
// 原生的数组join方法会将null转换为空字符串
807+
const flatRowKey = join(rowKey, this.stringJoinChar);
808+
const flatColKey = join(colKey, this.stringJoinChar);
808809

809810
//#region 收集用户传入的汇总数据到totalRecordsTree
810811
//该条数据为汇总数据

packages/vtable/src/layout/pivot-header-layout.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2344,8 +2344,12 @@ export class PivotHeaderLayoutMap implements LayoutMapAPI {
23442344
} = {};
23452345
rowHeaderPath.dimensionKey = rowHeader.dimensionKey;
23462346
rowHeaderPath.indicatorKey = rowHeader.indicatorKey;
2347+
// 如果value为null且没有indicatorKey时保持value为null(区分null和空字符串,防止单元格数据匹配不对)
23472348
rowHeaderPath.value =
2348-
rowHeader.value ?? this.getIndicatorInfoByIndicatorKey(rowHeader.indicatorKey)?.title ?? '';
2349+
rowHeader.value ??
2350+
(rowHeader.indicatorKey
2351+
? this.getIndicatorInfoByIndicatorKey(rowHeader.indicatorKey)?.title ?? ''
2352+
: rowHeader.value);
23492353
rowHeaderPath.virtual = rowHeader.virtual;
23502354
rowHeaderPath.role = rowHeader.role;
23512355
headerPaths.rowHeaderPaths!.push(rowHeaderPath);

0 commit comments

Comments
 (0)