mirror of
https://github.com/apache/superset.git
synced 2024-09-12 00:29:39 -04:00
fix: Adds time grain to Pivot Table v2 (#22170)
This commit is contained in:
parent
7e54b88a51
commit
9a2cb431ce
@ -144,6 +144,7 @@ export default function PivotTableChart(props: PivotTableProps) {
|
||||
metricColorFormatters,
|
||||
dateFormatters,
|
||||
onContextMenu,
|
||||
timeGrainSqla,
|
||||
} = props;
|
||||
|
||||
const theme = useTheme();
|
||||
@ -375,14 +376,15 @@ export default function PivotTableChart(props: PivotTableProps) {
|
||||
if (colKey && colKey.length > 1) {
|
||||
colKey.forEach((val, i) => {
|
||||
const col = cols[i];
|
||||
const formattedVal =
|
||||
dateFormatters[col]?.(val as number) || String(val);
|
||||
const formatter = dateFormatters[col];
|
||||
const formattedVal = formatter?.(val as number) || String(val);
|
||||
if (i > 0) {
|
||||
filters.push({
|
||||
col,
|
||||
op: '==',
|
||||
val,
|
||||
formattedVal,
|
||||
grain: formatter ? timeGrainSqla : undefined,
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -390,20 +392,21 @@ export default function PivotTableChart(props: PivotTableProps) {
|
||||
if (rowKey) {
|
||||
rowKey.forEach((val, i) => {
|
||||
const col = rows[i];
|
||||
const formattedVal =
|
||||
dateFormatters[col]?.(val as number) || String(val);
|
||||
const formatter = dateFormatters[col];
|
||||
const formattedVal = formatter?.(val as number) || String(val);
|
||||
filters.push({
|
||||
col,
|
||||
op: '==',
|
||||
val,
|
||||
formattedVal,
|
||||
grain: formatter ? timeGrainSqla : undefined,
|
||||
});
|
||||
});
|
||||
}
|
||||
onContextMenu(e.clientX, e.clientY, filters);
|
||||
}
|
||||
},
|
||||
[cols, dateFormatters, onContextMenu, rows],
|
||||
[cols, dateFormatters, onContextMenu, rows, timeGrainSqla],
|
||||
);
|
||||
|
||||
return (
|
||||
|
@ -101,6 +101,7 @@ export default function transformProps(chartProps: ChartProps<QueryFormData>) {
|
||||
emitFilter,
|
||||
metricsLayout,
|
||||
conditionalFormatting,
|
||||
timeGrainSqla,
|
||||
} = formData;
|
||||
const { selectedFilters } = filterState;
|
||||
const granularity = extractTimegrain(rawFormData);
|
||||
@ -165,5 +166,6 @@ export default function transformProps(chartProps: ChartProps<QueryFormData>) {
|
||||
metricColorFormatters,
|
||||
dateFormatters,
|
||||
onContextMenu,
|
||||
timeGrainSqla,
|
||||
};
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import {
|
||||
QueryFormMetric,
|
||||
QueryFormColumn,
|
||||
BinaryQueryObjectFilterClause,
|
||||
TimeGranularity,
|
||||
} from '@superset-ui/core';
|
||||
import { ColorFormatters } from '@superset-ui/chart-controls';
|
||||
|
||||
@ -78,6 +79,7 @@ interface PivotTableCustomizeProps {
|
||||
clientY: number,
|
||||
filters?: BinaryQueryObjectFilterClause[],
|
||||
) => void;
|
||||
timeGrainSqla?: TimeGranularity;
|
||||
}
|
||||
|
||||
export type PivotTableQueryFormData = QueryFormData &
|
||||
|
Loading…
Reference in New Issue
Block a user