feat(echarts): respect time grain in time-series tooltips (#41350)

Co-authored-by: Michael Gerber <michael.gerber@nxt.engineering>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Evan Rusackas
2026-07-17 09:41:04 -07:00
committed by GitHub
parent 60fb1c6f01
commit 9ccd365652
7 changed files with 282 additions and 24 deletions

View File

@@ -619,17 +619,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;
const deduplicatedFormatter = showMaxLabel
? (() => {
let lastLabel: string | undefined;
@@ -739,15 +747,15 @@ export default function transformProps(
},
minorTick: { show: minorTicks },
minInterval:
xAxisType === AxisType.Time && timeGrainSqla && !forceMaxInterval
? TIMEGRAIN_TO_TIMESTAMP[
timeGrainSqla as keyof typeof TIMEGRAIN_TO_TIMESTAMP
]
xAxisType === AxisType.Time && resolvedTimeGrain && !forceMaxInterval
? (TIMEGRAIN_TO_TIMESTAMP[
resolvedTimeGrain as keyof typeof TIMEGRAIN_TO_TIMESTAMP
] ?? 0)
: 0,
maxInterval:
xAxisType === AxisType.Time && timeGrainSqla && forceMaxInterval
xAxisType === AxisType.Time && resolvedTimeGrain && forceMaxInterval
? TIMEGRAIN_TO_TIMESTAMP[
timeGrainSqla as keyof typeof TIMEGRAIN_TO_TIMESTAMP
resolvedTimeGrain as keyof typeof TIMEGRAIN_TO_TIMESTAMP
]
: undefined,
...getMinAndMaxFromBounds(