feat(plugin-chart-table): table x-filtering supports single select (#1220)

* fix(plugin-chart-echarts): table support single select

* fix: remove comments
This commit is contained in:
Yaozong Liu
2021-07-20 11:54:56 +08:00
committed by Yongjie Zhao
parent 56146830f4
commit 631c867c46

View File

@@ -234,11 +234,13 @@ export default function TableChart<D extends DataRecord = DataRecord>(
const toggleFilter = useCallback(
function toggleFilter(key: string, val: DataRecordValue) {
const updatedFilters = { ...(filters || {}) };
let updatedFilters = { ...(filters || {}) };
if (filters && isActiveFilterValue(key, val)) {
updatedFilters[key] = filters[key].filter((x: DataRecordValue) => x !== val);
updatedFilters = {};
} else {
updatedFilters[key] = [...(filters?.[key] || []), val];
updatedFilters = {
[key]: [val],
};
}
if (Array.isArray(updatedFilters[key]) && updatedFilters[key].length === 0) {
delete updatedFilters[key];