mirror of
https://github.com/apache/superset.git
synced 2026-08-05 13:32:41 +00:00
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:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user