rusackas commented on code in PR #41350:
URL: https://github.com/apache/superset/pull/41350#discussion_r3477422747
##########
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts:
##########
@@ -871,7 +877,9 @@ export default function transformProps(
// "2005" appears twice with Year grain). Wrap the formatter to suppress
// consecutive duplicate labels.
const showMaxLabel =
- xAxisType === AxisType.Time && xAxisLabelRotation === 0 && !!timeGrainSqla;
+ xAxisType === AxisType.Time &&
+ xAxisLabelRotation === 0 &&
+ !!resolvedTimeGrain;
const deduplicatedFormatter = showMaxLabel
Review Comment:
I think the premise is off here. `showMaxLabel` was already gated on
`!!timeGrainSqla` on master, this PR just swaps it to `resolvedTimeGrain` so a
dashboard grain override also drives it. The no-grain behavior is unchanged, so
nothing regresses. Decoupling max-label forcing from grain entirely would be a
separate change from #37181.
##########
superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts:
##########
@@ -580,17 +580,25 @@ export default function transformProps(
if (maxSecondary === undefined) maxSecondary = 1;
}
+ // A dashboard-level time grain override (e.g. via a filter or the temporal
+ // range control) is delivered in extraFormData and should take precedence
+ // over the chart's own time grain when formatting temporal axes/tooltips.
+ const resolvedTimeGrain =
+ formData.extraFormData?.time_grain_sqla ?? timeGrainSqla;
+
const tooltipFormatter =
xAxisDataType === GenericDataType.Temporal
- ? getTooltipTimeFormatter(tooltipTimeFormat)
+ ? getTooltipTimeFormatter(tooltipTimeFormat, resolvedTimeGrain)
: String;
const xAxisFormatter =
xAxisDataType === GenericDataType.Temporal
- ? getXAxisFormatter(xAxisTimeFormat, timeGrainSqla)
+ ? getXAxisFormatter(xAxisTimeFormat, resolvedTimeGrain)
: String;
const showMaxLabel =
- xAxisType === AxisType.Time && xAxisLabelRotation === 0 && !!timeGrainSqla;
+ xAxisType === AxisType.Time &&
+ xAxisLabelRotation === 0 &&
+ !!resolvedTimeGrain;
Review Comment:
Same as the Timeseries thread, I think the premise is off. `showMaxLabel`
was already gated on `!!timeGrainSqla` on master, this PR just swaps it to
`resolvedTimeGrain` so a dashboard grain override drives it too. The no-grain
case is unchanged, so nothing regresses here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]