mirror of
https://github.com/apache/superset.git
synced 2026-05-12 19:35:17 +00:00
fix(chart): use categorical axis for bar charts with numeric x-axis (#39141)
Co-authored-by: Enzo Martellucci <52219496+EnxDev@users.noreply.github.com>
This commit is contained in:
@@ -258,7 +258,15 @@ export default function transformProps(
|
||||
|
||||
const dataTypes = getColtypesMapping(queriesData[0]);
|
||||
const xAxisDataType = dataTypes?.[xAxisLabel] ?? dataTypes?.[xAxisOrig];
|
||||
const xAxisType = getAxisType(stack, xAxisForceCategorical, xAxisDataType);
|
||||
const xAxisType = getAxisType(
|
||||
stack,
|
||||
xAxisForceCategorical,
|
||||
xAxisDataType,
|
||||
seriesType === EchartsTimeseriesSeriesType.Bar ||
|
||||
seriesTypeB === EchartsTimeseriesSeriesType.Bar
|
||||
? EchartsTimeseriesSeriesType.Bar
|
||||
: seriesType,
|
||||
);
|
||||
|
||||
const [rawSeriesA, sortedTotalValuesA] = extractSeries(rebasedDataA, {
|
||||
fillNeighborValue: stack ? 0 : undefined,
|
||||
|
||||
@@ -314,7 +314,12 @@ export default function transformProps(
|
||||
|
||||
const isMultiSeries = groupBy.length || metrics?.length > 1;
|
||||
const xAxisDataType = dataTypes?.[xAxisLabel] ?? dataTypes?.[xAxisOrig];
|
||||
const xAxisType = getAxisType(stack, xAxisForceCategorical, xAxisDataType);
|
||||
const xAxisType = getAxisType(
|
||||
stack,
|
||||
xAxisForceCategorical,
|
||||
xAxisDataType,
|
||||
seriesType,
|
||||
);
|
||||
|
||||
const [rawSeries, sortedTotalValues, minPositiveValue] = extractSeries(
|
||||
rebasedData,
|
||||
|
||||
@@ -934,6 +934,7 @@ export function getAxisType(
|
||||
stack: StackType,
|
||||
forceCategorical?: boolean,
|
||||
dataType?: GenericDataType,
|
||||
seriesType?: EchartsTimeseriesSeriesType,
|
||||
): AxisType {
|
||||
if (forceCategorical) {
|
||||
return AxisType.Category;
|
||||
@@ -941,7 +942,11 @@ export function getAxisType(
|
||||
if (dataType === GenericDataType.Temporal) {
|
||||
return AxisType.Time;
|
||||
}
|
||||
if (dataType === GenericDataType.Numeric && !stack) {
|
||||
if (
|
||||
dataType === GenericDataType.Numeric &&
|
||||
!stack &&
|
||||
seriesType !== EchartsTimeseriesSeriesType.Bar
|
||||
) {
|
||||
return AxisType.Value;
|
||||
}
|
||||
return AxisType.Category;
|
||||
|
||||
Reference in New Issue
Block a user