-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/TotalsDimGroup' into TotalsDimGroup
- Loading branch information
Showing
11 changed files
with
428 additions
and
169 deletions.
There are no files selected for viewing
252 changes: 252 additions & 0 deletions
252
packages/s2-core/__tests__/unit/data-process/new-total-spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,252 @@ | ||
/** | ||
* 透视表核心数据流程(保证基本数据正确) | ||
* */ | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import { Aggregation } from '@antv/s2'; | ||
import { assembleDataCfg, assembleOptions } from '../../util'; | ||
import { getContainer } from '../../util/helpers'; | ||
import { PivotSheet } from '@/sheet-type'; | ||
|
||
const myData = [ | ||
{ | ||
cost: 99099, | ||
number: 99099, | ||
city: '杭州市', | ||
type: '家具', | ||
sub_type: '桌子', | ||
}, | ||
{ | ||
cost: 99099, | ||
number: 99099, | ||
province: '浙江省', | ||
city: '杭州市', | ||
sub_type: '桌子', | ||
}, | ||
{ | ||
cost: 99099, | ||
number: 99099, | ||
province: '浙江省', | ||
city: '杭州市', | ||
type: '家具', | ||
}, | ||
{ | ||
cost: 99099, | ||
number: 99099, | ||
province: '浙江省', | ||
city: '杭州市', | ||
type: '家具', | ||
sub_type: '桌子', | ||
}, | ||
{ | ||
cost: 356, | ||
number: 3877, | ||
province: '浙江省', | ||
city: '宁波市', | ||
type: '家具', | ||
sub_type: '桌子', | ||
}, | ||
{ | ||
cost: 5734, | ||
number: 5343, | ||
province: '浙江省', | ||
city: '杭州市', | ||
type: '家具', | ||
sub_type: '沙发', | ||
}, | ||
{ | ||
cost: 957, | ||
number: 7234, | ||
province: '浙江省', | ||
city: '宁波市', | ||
type: '家具', | ||
sub_type: '沙发', | ||
}, | ||
{ | ||
cost: 486, | ||
number: 945, | ||
province: '浙江省', | ||
city: '杭州市', | ||
type: '办公用品', | ||
sub_type: '笔', | ||
}, | ||
{ | ||
cost: 357, | ||
number: 1145, | ||
province: '浙江省', | ||
city: '宁波市', | ||
type: '办公用品', | ||
sub_type: '笔', | ||
}, | ||
{ | ||
cost: 513, | ||
number: 1343, | ||
province: '浙江省', | ||
city: '杭州市', | ||
type: '办公用品', | ||
sub_type: '纸张', | ||
}, | ||
{ | ||
cost: 234, | ||
number: 1523, | ||
province: '浙江省', | ||
city: '宁波市', | ||
type: '办公用品', | ||
sub_type: '纸张', | ||
}, | ||
{ | ||
cost: 456, | ||
number: 1822, | ||
province: '四川省', | ||
city: '绵阳市', | ||
type: '家具', | ||
sub_type: '桌子', | ||
}, | ||
{ | ||
cost: 2654, | ||
number: 1943, | ||
province: '四川省', | ||
city: '南充市', | ||
type: '家具', | ||
sub_type: '桌子', | ||
}, | ||
{ | ||
cost: 578, | ||
number: 2244, | ||
province: '四川省', | ||
city: '绵阳市', | ||
type: '家具', | ||
sub_type: '沙发', | ||
}, | ||
{ | ||
cost: 687, | ||
number: 2333, | ||
province: '四川省', | ||
city: '南充市', | ||
type: '家具', | ||
sub_type: '沙发', | ||
}, | ||
{ | ||
cost: 345, | ||
number: 245, | ||
province: '四川省', | ||
city: '绵阳市', | ||
type: '办公用品', | ||
sub_type: '笔', | ||
}, | ||
{ | ||
cost: 756, | ||
number: 2457, | ||
province: '四川省', | ||
city: '南充市', | ||
type: '办公用品', | ||
sub_type: '笔', | ||
}, | ||
{ | ||
cost: 243, | ||
number: 3077, | ||
province: '四川省', | ||
city: '绵阳市', | ||
type: '办公用品', | ||
sub_type: '纸张', | ||
}, | ||
{ | ||
cost: 123, | ||
number: 3551, | ||
province: '四川省', | ||
city: '南充市', | ||
type: '办公用品', | ||
sub_type: '纸张', | ||
}, | ||
]; | ||
const meta = [ | ||
{ | ||
field: 'number', | ||
name: '数量', | ||
description: '数量说明。。', | ||
}, | ||
{ | ||
field: 'province', | ||
name: '省份', | ||
description: '省份说明。。', | ||
}, | ||
{ | ||
field: 'city', | ||
name: '城市', | ||
description: '城市说明。。', | ||
}, | ||
{ | ||
field: 'type', | ||
name: '类别', | ||
description: '类别说明。。', | ||
}, | ||
{ | ||
field: 'sub_type', | ||
name: '子类别', | ||
description: '子类别说明。。', | ||
}, | ||
{ | ||
field: 'cost', | ||
name: '价格', | ||
description: 'Value2', | ||
}, | ||
]; | ||
describe('Pivot Table Core Data Process', () => { | ||
const s2 = new PivotSheet( | ||
getContainer(), | ||
assembleDataCfg({ | ||
data: myData, | ||
meta, | ||
fields: { | ||
rows: ['province', 'city', 'type'], | ||
columns: ['sub_type'], | ||
values: ['number', 'cost'], | ||
valueInCols: false, | ||
// customValueOrder: 2, | ||
}, | ||
totalData: [], | ||
}), | ||
assembleOptions({ | ||
// hierarchyType: 'tree', | ||
debug: false, | ||
width: 1024, | ||
height: 2600, | ||
interaction: { | ||
brushSelection: { row: true }, | ||
enableCopy: true, | ||
}, | ||
totals: { | ||
row: { | ||
totalsDimensionsGroup: ['city', 'type'], | ||
subTotalsDimensionsGroup: ['sub_type'], | ||
calcTotals: { | ||
aggregation: Aggregation.SUM, | ||
}, | ||
calcSubTotals: { | ||
aggregation: Aggregation.SUM, | ||
}, | ||
showGrandTotals: true, | ||
showSubTotals: true, | ||
reverseLayout: true, | ||
reverseSubLayout: true, | ||
subTotalsDimensions: ['province'], | ||
}, | ||
// col: { | ||
// subTotalsDimensionsGroup: ['city'], | ||
// totalsDimensionsGroup: ['sub_type'], | ||
// calcTotals: { | ||
// aggregation: Aggregation.SUM, | ||
// }, | ||
// calcSubTotals: { | ||
// aggregation: Aggregation.SUM, | ||
// }, | ||
// showGrandTotals: true, | ||
// showSubTotals: true, | ||
// reverseLayout: true, | ||
// reverseSubLayout: true, | ||
// subTotalsDimensions: ['province'], | ||
// }, | ||
}, | ||
}), | ||
); | ||
s2.render(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/s2-core/src/data-set/README-adjustTotalNodesCoordinate.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.