Skip to content

Commit

Permalink
fix(plugin-chart-pivot-table): cross filtering by adhoc column (#1465)
Browse files Browse the repository at this point in the history
  • Loading branch information
kgabryje authored and zhaoyongjie committed Nov 26, 2021
1 parent 852478b commit 2b8e4a1
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
DataRecordValue,
getColumnLabel,
getNumberFormatter,
isPhysicalColumn,
NumberFormatter,
styled,
useTheme,
Expand All @@ -35,6 +36,7 @@ import {
// @ts-ignore
} from '@superset-ui/react-pivottable/Utilities';
import '@superset-ui/react-pivottable/pivottable.css';
import { isAdhocColumn } from '@superset-ui/chart-controls';
import {
FilterType,
MetricsLayoutEnum,
Expand Down Expand Up @@ -192,14 +194,25 @@ export default function PivotTableChart(props: PivotTableProps) {

const handleChange = useCallback(
(filters: SelectedFiltersType) => {
const groupBy = Object.keys(filters);
const filterKeys = Object.keys(filters);
const groupby = [...groupbyRowsRaw, ...groupbyColumnsRaw];
setDataMask({
extraFormData: {
filters:
groupBy.length === 0
filterKeys.length === 0
? undefined
: groupBy.map(col => {
const val = filters?.[col];
: filterKeys.map(key => {
const val = filters?.[key];
const col =
groupby.find(item => {
if (isPhysicalColumn(item)) {
return item === key;
}
if (isAdhocColumn(item)) {
return item.label === key;
}
return false;
}) ?? '';
if (val === null || val === undefined)
return {
col,
Expand Down

0 comments on commit 2b8e4a1

Please sign in to comment.