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 8bc01582af4ab..f924ad6f9ba36 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts @@ -223,7 +223,7 @@ export default function transformProps( const dataTypes = getColtypesMapping(queriesData[0]); const xAxisDataType = dataTypes?.[xAxisLabel] ?? dataTypes?.[xAxisOrig]; - const xAxisType = getAxisType(xAxisDataType); + const xAxisType = getAxisType(stack, xAxisDataType); const series: SeriesOption[] = []; const formatter = contributionMode ? getNumberFormatter(',.0%') diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts index e42ac183b6cfe..8dd9966484e8d 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts @@ -247,7 +247,7 @@ export default function transformProps( const isAreaExpand = stack === StackControlsValue.Expand; const xAxisDataType = dataTypes?.[xAxisLabel] ?? dataTypes?.[xAxisOrig]; - const xAxisType = getAxisType(xAxisDataType); + const xAxisType = getAxisType(stack, xAxisDataType); const series: SeriesOption[] = []; const forcePercentFormatter = Boolean(contributionMode || isAreaExpand); diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts b/superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts index aa353f66d1a2e..69c0ccbe1ba51 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts @@ -508,11 +508,14 @@ export function sanitizeHtml(text: string): string { return format.encodeHTML(text); } -export function getAxisType(dataType?: GenericDataType): AxisType { +export function getAxisType( + stack: StackType, + dataType?: GenericDataType, +): AxisType { if (dataType === GenericDataType.TEMPORAL) { return AxisType.time; } - if (dataType === GenericDataType.NUMERIC) { + if (dataType === GenericDataType.NUMERIC && !stack) { return AxisType.value; } return AxisType.category; diff --git a/superset-frontend/plugins/plugin-chart-echarts/test/utils/series.test.ts b/superset-frontend/plugins/plugin-chart-echarts/test/utils/series.test.ts index b445dceabbd47..b309bf6f3c730 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/test/utils/series.test.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/test/utils/series.test.ts @@ -875,10 +875,13 @@ test('calculateLowerLogTick', () => { }); test('getAxisType', () => { - expect(getAxisType(GenericDataType.TEMPORAL)).toEqual(AxisType.time); - expect(getAxisType(GenericDataType.NUMERIC)).toEqual(AxisType.value); - expect(getAxisType(GenericDataType.BOOLEAN)).toEqual(AxisType.category); - expect(getAxisType(GenericDataType.STRING)).toEqual(AxisType.category); + expect(getAxisType(false, GenericDataType.TEMPORAL)).toEqual(AxisType.time); + expect(getAxisType(false, GenericDataType.NUMERIC)).toEqual(AxisType.value); + expect(getAxisType(true, GenericDataType.NUMERIC)).toEqual(AxisType.category); + expect(getAxisType(false, GenericDataType.BOOLEAN)).toEqual( + AxisType.category, + ); + expect(getAxisType(false, GenericDataType.STRING)).toEqual(AxisType.category); }); test('getMinAndMaxFromBounds returns empty object when not truncating', () => {