-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: only omit undefined row cell (#861)
* fix: only omit undefined values * test: add unit test for empty string field * test: add null and undefined test data
- Loading branch information
Showing
4 changed files
with
135 additions
and
3 deletions.
There are no files selected for viewing
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,30 @@ | ||
/** | ||
* @description spec for issue #860 | ||
* https://github.com/antvis/S2/issues/860 | ||
* Column should not be formatted | ||
* | ||
*/ | ||
import { getContainer } from 'tests/util/helpers'; | ||
import dataCfg from '../data/data-issue-860.json'; | ||
import { PivotSheet, SpreadSheet } from '@/sheet-type'; | ||
import { S2Options } from '@/common/interface'; | ||
|
||
const s2options: S2Options = { | ||
width: 600, | ||
height: 400, | ||
frozenRowHeader: false, | ||
}; | ||
|
||
describe('Column Formatter Tests', () => { | ||
let s2: SpreadSheet; | ||
|
||
beforeEach(() => { | ||
s2 = new PivotSheet(getContainer(), dataCfg, s2options); | ||
s2.render(); | ||
}); | ||
test('should get correct row hierarchy with empty row node', () => { | ||
const layoutResult = s2.facet.layoutResult; | ||
expect(layoutResult.rowNodes).toHaveLength(8); | ||
expect(layoutResult.rowLeafNodes).toHaveLength(5); | ||
}); | ||
}); |
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,74 @@ | ||
{ | ||
"fields": { | ||
"rows": ["date", "city", "type"], | ||
"columns": [], | ||
"values": ["a_sum", "b_sum"], | ||
"valueInCols": true | ||
}, | ||
"meta": [ | ||
{ | ||
"field": "date", | ||
"name": "日期" | ||
}, | ||
{ | ||
"field": "city", | ||
"name": "城市" | ||
}, | ||
{ | ||
"field": "type", | ||
"name": "类型" | ||
}, | ||
{ | ||
"field": "a_sum", | ||
"name": "A类求和" | ||
}, | ||
{ | ||
"field": "b_sum", | ||
"name": "B类求和" | ||
} | ||
], | ||
"data": [ | ||
{ | ||
"date": "2021-12-01", | ||
"city": "A市", | ||
"type": "电子", | ||
"a_sum": 6 | ||
}, | ||
{ | ||
"date": "2021-12-01", | ||
"city": "A市", | ||
"type": "电子", | ||
"b_sum": 6 | ||
}, | ||
{ | ||
"date": "2021-12-01", | ||
"city": "A市", | ||
"type": "", | ||
"b_sum": 6 | ||
}, | ||
{ | ||
"date": "2021-12-01", | ||
"city": "A市", | ||
"type": "undefined", | ||
"b_sum": 6 | ||
}, | ||
{ | ||
"date": "2021-12-01", | ||
"city": "A市", | ||
"type": null, | ||
"b_sum": 6 | ||
}, | ||
{ | ||
"date": "2021-12-01", | ||
"city": "B市", | ||
"type": "日用", | ||
"a_sum": 1 | ||
}, | ||
{ | ||
"date": "2021-12-01", | ||
"city": "B市", | ||
"type": "", | ||
"b_sum": 1 | ||
} | ||
] | ||
} |
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
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