Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

fix(plugin-chart-pivot-table): cross filtering by adhoc column #1465

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions plugins/plugin-chart-pivot-table/src/PivotTableChart.tsx
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