diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts index b1655e38d1d..71dc91183a9 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts @@ -578,9 +578,31 @@ export default function transformProps( : String; const xAxisFormatter = xAxisDataType === GenericDataType.Temporal - ? getXAxisFormatter(xAxisTimeFormat) + ? getXAxisFormatter(xAxisTimeFormat, timeGrainSqla) : String; + const showMaxLabel = xAxisType === AxisType.Time && xAxisLabelRotation === 0; + const deduplicatedFormatter = showMaxLabel + ? (() => { + let lastLabel: string | undefined; + const wrapper = (value: number | string) => { + const label = + typeof xAxisFormatter === 'function' + ? (xAxisFormatter as Function)(value) + : String(value); + if (label === lastLabel) { + return ''; + } + lastLabel = label; + return label; + }; + if (typeof xAxisFormatter === 'function' && 'id' in xAxisFormatter) { + (wrapper as any).id = (xAxisFormatter as any).id; + } + return wrapper; + })() + : xAxisFormatter; + const addYAxisTitleOffset = !!(yAxisTitle || yAxisTitleSecondary) && convertInteger(yAxisTitleMargin) !== 0; @@ -658,9 +680,14 @@ export default function transformProps( nameGap: convertInteger(xAxisTitleMargin), nameLocation: 'middle', axisLabel: { - formatter: xAxisFormatter, + hideOverlap: !(xAxisType === AxisType.Time && xAxisLabelRotation !== 0), + formatter: deduplicatedFormatter, rotate: xAxisLabelRotation, interval: xAxisLabelInterval, + ...(showMaxLabel && { + showMaxLabel: true, + alignMaxLabel: 'right', + }), }, minorTick: { show: minorTicks }, minInterval: