Skip to content

Commit

Permalink
fix(plugin-chart-pivot-table): pivot table supports single select (#1221
Browse files Browse the repository at this point in the history
)
  • Loading branch information
stephenLYZ authored and zhaoyongjie committed Nov 26, 2021
1 parent 844c069 commit 89474f8
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,20 @@ export default function PivotTableChart(props: PivotTableProps) {

const [key, val] = filtersEntries[filtersEntries.length - 1];

const updatedFilters = { ...(selectedFilters || {}) };
let updatedFilters = { ...(selectedFilters || {}) };
// multi select
// if (selectedFilters && isActiveFilterValue(key, val)) {
// updatedFilters[key] = selectedFilters[key].filter((x: DataRecordValue) => x !== val);
// } else {
// updatedFilters[key] = [...(selectedFilters?.[key] || []), val];
// }
// single select
if (selectedFilters && isActiveFilterValue(key, val)) {
updatedFilters[key] = selectedFilters[key].filter((x: DataRecordValue) => x !== val);
updatedFilters = {};
} else {
updatedFilters[key] = [...(selectedFilters?.[key] || []), val];
updatedFilters = {
[key]: [val],
};
}
if (Array.isArray(updatedFilters[key]) && updatedFilters[key].length === 0) {
delete updatedFilters[key];
Expand Down

0 comments on commit 89474f8

Please sign in to comment.