mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
fix: Adds time grain to Pivot Table v2 (#22170)
This commit is contained in:
committed by
GitHub
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 (
|
||||
|
||||
Reference in New Issue
Block a user