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

feat: 小计/总计功能,支持按维度分组汇总 #2337 #2338

Merged
merged 51 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
9b5f285
feat(Api): 添加 totalDimensionGroup/subTotalDimensionGroup api,以及一些临时的开发函数
Aug 24, 2023
66b6337
feat(Hierarchy): 总计小计结点下添加Hierarchy
Aug 25, 2023
800a919
feat(Render): getMultipleMap 实现,计算总计小计下的布局信息
Aug 25, 2023
a39c9ed
feat(Render): 按维度分组的小计总计下表头位置的调整和渲染
Aug 27, 2023
d07e072
feat(DataSet): 存在维度分组时的汇总值获取
Aug 29, 2023
14a667a
feat(DataSet): 存在维度分组时的汇总值获取
Aug 30, 2023
e9d7e56
feat(DataSet): 存在维度分组时的汇总值获取
Aug 30, 2023
4ed13e1
feat: 补充注释
Aug 30, 2023
5707e73
feat: 单测快照更新,添加isTotalRoot属性
Aug 31, 2023
2d1c143
fix: 有多个 Value 时不允许隐藏度量列
Aug 31, 2023
0c1686b
fix: 有多个 Value 时不允许隐藏度量列
Aug 31, 2023
68e98fe
fix: 删除了一个莫名其妙的函数
Aug 31, 2023
0b472c5
Merge branch 'master' into Juze_TotalsDimGroup
Aug 31, 2023
ae46e08
test: 按维度分组汇总能力单测
Aug 31, 2023
209e5f5
docs: 按维度分组汇总能力文档
Sep 1, 2023
a53cd1c
test: 更新,多度量指标不允许隐藏指标头
Sep 1, 2023
4bdab0f
docs: 图片示例
Sep 1, 2023
fd0151a
test: 更新 snap 数据文件
Sep 4, 2023
a56eca1
Merge branch 'antvis:master' into Juze_TotalsDimGroup
NoobNotN Sep 4, 2023
288c124
chore: 版本号更新
Sep 4, 2023
d2ef9a9
Merge remote-tracking branch 'origin/Juze_TotalsDimGroup' into Juze_T…
Sep 4, 2023
f733e64
chore: 版本号更新
Sep 4, 2023
72321d6
chore: 版本号更新
Sep 4, 2023
ce70d04
chore: 版本号更新
Sep 4, 2023
1638888
chore: 版本号更新
Sep 4, 2023
2ce87cd
chore: 版本号更新
Sep 4, 2023
72db41a
chore: 版本号更新
Sep 4, 2023
6e20190
Merge remote-tracking branch 'origin/Juze_TotalsDimGroup' into Juze_T…
Sep 4, 2023
9d9721e
Merge remote-tracking branch 'origin/Juze_TotalsDimGroup' into Juze_T…
Sep 4, 2023
e78b4be
Merge remote-tracking branch 'origin/Juze_TotalsDimGroup' into Juze_T…
Sep 4, 2023
a14e5f8
Merge remote-tracking branch 'origin/Juze_TotalsDimGroup' into Juze_T…
Sep 4, 2023
d78f5e9
Merge remote-tracking branch 'origin/Juze_TotalsDimGroup' into Juze_T…
Sep 4, 2023
482e1f4
Merge remote-tracking branch 'origin/Juze_TotalsDimGroup' into Juze_T…
Sep 4, 2023
e2f0ce1
test: 更新快照
Sep 4, 2023
0e583e7
Merge remote-tracking branch 'origin/Juze_TotalsDimGroup' into Juze_T…
Sep 4, 2023
0424794
Merge remote-tracking branch 'origin/Juze_TotalsDimGroup' into Juze_T…
Sep 4, 2023
8edb616
Merge remote-tracking branch 'origin/TotalsDimGroup' into TotalsDimGroup
Sep 4, 2023
405a73f
Merge remote-tracking branch 'origin/TotalsDimGroup' into TotalsDimGroup
Sep 4, 2023
57db05a
Merge remote-tracking branch 'origin/TotalsDimGroup' into TotalsDimGroup
Sep 5, 2023
14692d8
Merge remote-tracking branch 'origin/TotalsDimGroup' into TotalsDimGroup
Sep 5, 2023
3e3c847
Merge remote-tracking branch 'origin/TotalsDimGroup' into TotalsDimGroup
Sep 6, 2023
17120dc
Merge remote-tracking branch 'origin/TotalsDimGroup' into TotalsDimGroup
Sep 6, 2023
94d81ad
Merge remote-tracking branch 'origin/TotalsDimGroup' into TotalsDimGroup
Sep 6, 2023
6ddf80b
Merge remote-tracking branch 'origin/TotalsDimGroup' into TotalsDimGroup
Sep 6, 2023
d5fc742
Merge remote-tracking branch 'origin/TotalsDimGroup' into TotalsDimGroup
Sep 6, 2023
5c11b4d
chore: 删除开发测试文件
Sep 6, 2023
8550e31
fix: 汇总指标节点也是汇总节点
Sep 6, 2023
3bf638d
chore: 删除无用文件
Sep 6, 2023
8c36de6
fix: isTotalRoot 替换 isTotals
Sep 7, 2023
ce4aa59
fix: isTotalRoot 替换 isTotals
Sep 7, 2023
e51ab22
fix: isTotalRoot 替换 isTotals
Sep 7, 2023
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
7 changes: 4 additions & 3 deletions packages/s2-core/__tests__/bugs/issue-1715-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@ describe('Multi Values GrandTotal Height Test', () => {

const grandTotalsNode = s2
.getColumnNodes()
.find((node) => node.isGrandTotals);
.find((node) => node.isGrandTotals && node.isTotalRoot);

expect(s2.facet.layoutResult.colsHierarchy.height).toBe(60);
expect(grandTotalsNode.height).toEqual(30);
// 有多个 Value 时不允许隐藏度量列
expect(s2.facet.layoutResult.colsHierarchy.height).toBe(90);
expect(grandTotalsNode.height).toEqual(60);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Array [
"isPivotMode": true,
"isSubTotals": undefined,
"isTotalMeasure": undefined,
"isTotalRoot": undefined,
"isTotals": undefined,
"key": "province",
"label": "province",
Expand Down Expand Up @@ -47,6 +48,7 @@ Array [
"isPivotMode": true,
"isSubTotals": undefined,
"isTotalMeasure": undefined,
"isTotalRoot": undefined,
"isTotals": undefined,
"key": "city",
"label": "city",
Expand Down Expand Up @@ -81,6 +83,7 @@ Array [
"isPivotMode": true,
"isSubTotals": undefined,
"isTotalMeasure": undefined,
"isTotalRoot": undefined,
"isTotals": undefined,
"key": "series-number-node",
"label": "序号",
Expand Down Expand Up @@ -110,6 +113,7 @@ Array [
"isPivotMode": true,
"isSubTotals": undefined,
"isTotalMeasure": undefined,
"isTotalRoot": undefined,
"isTotals": undefined,
"key": "province",
"label": "province",
Expand Down Expand Up @@ -139,6 +143,7 @@ Array [
"isPivotMode": true,
"isSubTotals": undefined,
"isTotalMeasure": undefined,
"isTotalRoot": undefined,
"isTotals": undefined,
"key": "city",
"label": "city",
Expand Down Expand Up @@ -173,6 +178,7 @@ Array [
"isPivotMode": true,
"isSubTotals": undefined,
"isTotalMeasure": undefined,
"isTotalRoot": undefined,
"isTotals": undefined,
"key": "",
"label": "province/city/数值",
Expand Down Expand Up @@ -207,6 +213,7 @@ Array [
"isPivotMode": true,
"isSubTotals": undefined,
"isTotalMeasure": undefined,
"isTotalRoot": undefined,
"isTotals": undefined,
"key": "series-number-node",
"label": "序号",
Expand Down Expand Up @@ -236,6 +243,7 @@ Array [
"isPivotMode": true,
"isSubTotals": undefined,
"isTotalMeasure": undefined,
"isTotalRoot": undefined,
"isTotals": undefined,
"key": "",
"label": "province/city/数值",
Expand Down Expand Up @@ -270,6 +278,7 @@ Array [
"isPivotMode": true,
"isSubTotals": undefined,
"isTotalMeasure": undefined,
"isTotalRoot": undefined,
"isTotals": undefined,
"key": "province",
"label": "province",
Expand Down Expand Up @@ -299,6 +308,7 @@ Array [
"isPivotMode": true,
"isSubTotals": undefined,
"isTotalMeasure": undefined,
"isTotalRoot": undefined,
"isTotals": undefined,
"key": "city",
"label": "city",
Expand Down Expand Up @@ -333,6 +343,7 @@ Array [
"isPivotMode": true,
"isSubTotals": undefined,
"isTotalMeasure": undefined,
"isTotalRoot": undefined,
"isTotals": undefined,
"key": "series-number-node",
"label": "序号",
Expand Down Expand Up @@ -362,6 +373,7 @@ Array [
"isPivotMode": true,
"isSubTotals": undefined,
"isTotalMeasure": undefined,
"isTotalRoot": undefined,
"isTotals": undefined,
"key": "province",
"label": "province",
Expand Down Expand Up @@ -391,6 +403,7 @@ Array [
"isPivotMode": true,
"isSubTotals": undefined,
"isTotalMeasure": undefined,
"isTotalRoot": undefined,
"isTotals": undefined,
"key": "city",
"label": "city",
Expand Down Expand Up @@ -425,6 +438,7 @@ Array [
"isPivotMode": true,
"isSubTotals": undefined,
"isTotalMeasure": undefined,
"isTotalRoot": undefined,
"isTotals": undefined,
"key": "",
"label": "province/city",
Expand Down Expand Up @@ -459,6 +473,7 @@ Array [
"isPivotMode": true,
"isSubTotals": undefined,
"isTotalMeasure": undefined,
"isTotalRoot": undefined,
"isTotals": undefined,
"key": "series-number-node",
"label": "序号",
Expand Down Expand Up @@ -488,6 +503,7 @@ Array [
"isPivotMode": true,
"isSubTotals": undefined,
"isTotalMeasure": undefined,
"isTotalRoot": undefined,
"isTotals": undefined,
"key": "",
"label": "province/city",
Expand Down Expand Up @@ -522,6 +538,7 @@ Array [
"isPivotMode": true,
"isSubTotals": undefined,
"isTotalMeasure": undefined,
"isTotalRoot": undefined,
"isTotals": undefined,
"key": "province",
"label": "province",
Expand Down Expand Up @@ -551,6 +568,7 @@ Array [
"isPivotMode": true,
"isSubTotals": undefined,
"isTotalMeasure": undefined,
"isTotalRoot": undefined,
"isTotals": undefined,
"key": "city",
"label": "city",
Expand Down Expand Up @@ -585,6 +603,7 @@ Array [
"isPivotMode": true,
"isSubTotals": undefined,
"isTotalMeasure": undefined,
"isTotalRoot": undefined,
"isTotals": undefined,
"key": "series-number-node",
"label": "序号",
Expand Down Expand Up @@ -614,6 +633,7 @@ Array [
"isPivotMode": true,
"isSubTotals": undefined,
"isTotalMeasure": undefined,
"isTotalRoot": undefined,
"isTotals": undefined,
"key": "province",
"label": "province",
Expand Down Expand Up @@ -643,6 +663,7 @@ Array [
"isPivotMode": true,
"isSubTotals": undefined,
"isTotalMeasure": undefined,
"isTotalRoot": undefined,
"isTotals": undefined,
"key": "city",
"label": "city",
Expand Down Expand Up @@ -677,6 +698,7 @@ Array [
"isPivotMode": true,
"isSubTotals": undefined,
"isTotalMeasure": undefined,
"isTotalRoot": undefined,
"isTotals": undefined,
"key": "",
"label": "province/city",
Expand Down Expand Up @@ -711,6 +733,7 @@ Array [
"isPivotMode": true,
"isSubTotals": undefined,
"isTotalMeasure": undefined,
"isTotalRoot": undefined,
"isTotals": undefined,
"key": "series-number-node",
"label": "序号",
Expand Down Expand Up @@ -740,6 +763,7 @@ Array [
"isPivotMode": true,
"isSubTotals": undefined,
"isTotalMeasure": undefined,
"isTotalRoot": undefined,
"isTotals": undefined,
"key": "",
"label": "province/city",
Expand Down
8 changes: 8 additions & 0 deletions packages/s2-core/__tests__/spreadsheet/corner-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe('PivotSheet Corner Tests', () => {
fields: {
...simpleDataConfig.fields,
columns: [],
values: ['price'],
},
});
s2.setOptions({
Expand Down Expand Up @@ -88,6 +89,13 @@ describe('PivotSheet Corner Tests', () => {
},
},
});
s2.setDataCfg({
...simpleDataConfig,
fields: {
...simpleDataConfig.fields,
values: ['price'],
},
});
s2.render();

const cornerNodes = s2.facet.getCornerNodes();
Expand Down
11 changes: 11 additions & 0 deletions packages/s2-core/__tests__/spreadsheet/sort-by-order-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,15 @@ describe('Manual Sort Tests', () => {
}),
).toEqual(['整体访问', '小程序访问', '支付宝访问']);
});

test('getTotalDimensionValues should include correct values', () => {
const sortedType1 = s2.dataSet.getTotalDimensionValues('type1', {});
expect(sortedType1).toEqual(['整体访问', '小程序访问', '支付宝访问']);

expect(s2.dataSet.getTotalDimensionValues('type2', {})).toEqual([
'整体访问',
'小程序访问',
'支付宝访问',
]);
});
});
4 changes: 2 additions & 2 deletions packages/s2-core/__tests__/unit/cell/header-cell-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,21 @@
});

test('should not format pivot col and row total cell', () => {
const colNode = new Node({

Check warning on line 57 in packages/s2-core/__tests__/unit/cell/header-cell-spec.ts

View workflow job for this annotation

GitHub Actions / lint (18)

'colNode' is already declared in the upper scope

Check warning on line 57 in packages/s2-core/__tests__/unit/cell/header-cell-spec.ts

View workflow job for this annotation

GitHub Actions / lint (18)

'colNode' is already declared in the upper scope
id: `root[&]总计`,
key: '',
value: '总计',
parent: root,
label: '总计',
isTotals: true,
isTotalRoot: true,
});
const rowNode = new Node({

Check warning on line 65 in packages/s2-core/__tests__/unit/cell/header-cell-spec.ts

View workflow job for this annotation

GitHub Actions / lint (18)

'rowNode' is already declared in the upper scope

Check warning on line 65 in packages/s2-core/__tests__/unit/cell/header-cell-spec.ts

View workflow job for this annotation

GitHub Actions / lint (18)

'rowNode' is already declared in the upper scope
id: `root[&]杭州[&]小计`,
key: '',
value: '小计',
parent: root,
label: '小计',
isTotals: true,
isTotalRoot: true,
});

const formatter: Formatter = (value) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Pivot Dataset Total Test test for total with dimension group get correct MultiData when query need to be processed 1`] = `
Array [
Object {
"$$extra$$": "number",
"$$value$$": 7789,
"city": "杭州市",
"number": 7789,
"province": "浙江省",
"sub_type": "桌子",
"type": "家具",
},
Object {
"$$extra$$": "number",
"$$value$$": 2367,
"city": "绍兴市",
"number": 2367,
"province": "浙江省",
"sub_type": "桌子",
"type": "家具",
},
Object {
"$$extra$$": "number",
"$$value$$": 3877,
"city": "宁波市",
"number": 3877,
"province": "浙江省",
"sub_type": "桌子",
"type": "家具",
},
Object {
"$$extra$$": "number",
"$$value$$": 4342,
"city": "舟山市",
"number": 4342,
"province": "浙江省",
"sub_type": "桌子",
"type": "家具",
},
]
`;

exports[`Pivot Dataset Total Test test for total with dimension group get correct MultiData when query need to be processed 2`] = `Array []`;

exports[`Pivot Dataset Total Test test for total with dimension group get correct MultiData when query need to be processed 3`] = `
Array [
Object {
"$$extra$$": "number",
"$$value$$": 7789,
"city": "杭州市",
"number": 7789,
"province": "浙江省",
"sub_type": "桌子",
"type": "家具",
},
Object {
"$$extra$$": "number",
"$$value$$": 2367,
"city": "绍兴市",
"number": 2367,
"province": "浙江省",
"sub_type": "桌子",
"type": "家具",
},
Object {
"$$extra$$": "number",
"$$value$$": 3877,
"city": "宁波市",
"number": 3877,
"province": "浙江省",
"sub_type": "桌子",
"type": "家具",
},
Object {
"$$extra$$": "number",
"$$value$$": 4342,
"city": "舟山市",
"number": 4342,
"province": "浙江省",
"sub_type": "桌子",
"type": "家具",
},
Object {
"$$extra$$": "number",
"$$value$$": 1723,
"city": "成都市",
"number": 1723,
"province": "四川省",
"sub_type": "桌子",
"type": "家具",
},
Object {
"$$extra$$": "number",
"$$value$$": 1822,
"city": "绵阳市",
"number": 1822,
"province": "四川省",
"sub_type": "桌子",
"type": "家具",
},
Object {
"$$extra$$": "number",
"$$value$$": 1943,
"city": "南充市",
"number": 1943,
"province": "四川省",
"sub_type": "桌子",
"type": "家具",
},
Object {
"$$extra$$": "number",
"$$value$$": 2330,
"city": "乐山市",
"number": 2330,
"province": "四川省",
"sub_type": "桌子",
"type": "家具",
},
]
`;
Loading
Loading