-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(table-facet): 修复过滤多列时,删除一列过滤将同时清空后续过滤列 (#2323)
- Loading branch information
Showing
3 changed files
with
193 additions
and
1 deletion.
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,45 @@ | ||
/** | ||
* @description spec for issue #2322 | ||
* https://github.com/antvis/S2/issues/2322 | ||
* 明细表: 多列筛选后清空其中一列筛选,导致其他筛选也清空 | ||
*/ | ||
import { getContainer } from 'tests/util/helpers'; | ||
import dataCfg from '../data/data-issue-2322.json'; | ||
import { TableSheet } from '@/sheet-type'; | ||
import type { S2Options } from '@/common/interface'; | ||
import { S2Event } from '@/common'; | ||
|
||
const s2Options: S2Options = { | ||
width: 300, | ||
height: 480, | ||
showSeriesNumber: true, | ||
frozenColCount: 1, | ||
}; | ||
|
||
describe('Table Sheet Filter Test', () => { | ||
test('should filter correctly when part of the filter is cleaned', () => { | ||
const s2 = new TableSheet(getContainer(), dataCfg, s2Options); | ||
s2.render(); | ||
|
||
// 为两个不同的列设定过滤 | ||
s2.emit(S2Event.RANGE_FILTER, { | ||
filterKey: 'province', | ||
filteredValues: ['吉林'], | ||
}); | ||
s2.emit(S2Event.RANGE_FILTER, { | ||
filterKey: 'city', | ||
filteredValues: ['杭州'], | ||
}); | ||
|
||
// 删除一列过滤 | ||
s2.emit(S2Event.RANGE_FILTER, { | ||
filterKey: 'province', | ||
filteredValues: [], | ||
}); | ||
|
||
// 应过滤掉 city = 杭州 的值,共4行 | ||
expect(s2.dataSet.getDisplayDataSet().length).toBe( | ||
s2.dataSet.originData.length - 4, | ||
); | ||
}); | ||
}); |
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,147 @@ | ||
{ | ||
"fields": { | ||
"columns": [ | ||
{ | ||
"key": "area", | ||
"children": ["province", "city"] | ||
}, | ||
"type", | ||
{ | ||
"key": "money", | ||
"children": [ | ||
{ | ||
"key": "price" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"meta": [ | ||
{ | ||
"field": "province", | ||
"name": "省份" | ||
}, | ||
{ | ||
"field": "city", | ||
"name": "城市" | ||
}, | ||
{ | ||
"field": "type", | ||
"name": "商品类别" | ||
}, | ||
{ | ||
"field": "price", | ||
"name": "价格" | ||
}, | ||
{ | ||
"field": "cost", | ||
"name": "成本" | ||
}, | ||
{ | ||
"field": "area", | ||
"name": "位置" | ||
}, | ||
{ | ||
"field": "money", | ||
"name": "金额" | ||
} | ||
], | ||
"data": [ | ||
{ | ||
"province": "浙江", | ||
"city": "杭州", | ||
"type": "笔", | ||
"price": 1 | ||
}, | ||
{ | ||
"province": "浙江", | ||
"city": "杭州", | ||
"type": "纸张", | ||
"price": 2 | ||
}, | ||
{ | ||
"province": "浙江", | ||
"city": "舟山", | ||
"type": "笔", | ||
"price": 17 | ||
}, | ||
{ | ||
"province": "浙江", | ||
"city": "舟山", | ||
"type": "纸张", | ||
"price": 6 | ||
}, | ||
{ | ||
"province": "吉林", | ||
"city": "长春", | ||
"type": "笔", | ||
"price": 8 | ||
}, | ||
{ | ||
"province": "吉林", | ||
"city": "白山", | ||
"type": "笔", | ||
"price": 12 | ||
}, | ||
{ | ||
"province": "吉林", | ||
"city": "长春", | ||
"type": "纸张", | ||
"price": 3 | ||
}, | ||
{ | ||
"province": "吉林", | ||
"city": "白山", | ||
"type": "纸张", | ||
"price": 25 | ||
}, | ||
{ | ||
"province": "浙江", | ||
"city": "杭州", | ||
"type": "笔", | ||
"price": 20 | ||
}, | ||
{ | ||
"province": "浙江", | ||
"city": "杭州", | ||
"type": "纸张", | ||
"price": 10 | ||
}, | ||
{ | ||
"province": "浙江", | ||
"city": "舟山", | ||
"type": "笔", | ||
"price": 15 | ||
}, | ||
{ | ||
"province": "浙江", | ||
"city": "舟山", | ||
"type": "纸张", | ||
"price": 2 | ||
}, | ||
{ | ||
"province": "吉林", | ||
"city": "长春", | ||
"type": "笔", | ||
"price": 15 | ||
}, | ||
{ | ||
"province": "吉林", | ||
"city": "白山", | ||
"type": "笔", | ||
"price": 30 | ||
}, | ||
{ | ||
"province": "吉林", | ||
"city": "长春", | ||
"type": "纸张", | ||
"price": 40 | ||
}, | ||
{ | ||
"province": "吉林", | ||
"city": "白山", | ||
"type": "纸张", | ||
"price": 50 | ||
} | ||
] | ||
} |
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