Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Stacked charts with numerical columns #26264

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@

const dataTypes = getColtypesMapping(queriesData[0]);
const xAxisDataType = dataTypes?.[xAxisLabel] ?? dataTypes?.[xAxisOrig];
const xAxisType = getAxisType(xAxisDataType);
const xAxisType = getAxisType(stack, xAxisDataType);

Check warning on line 226 in superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts

View check run for this annotation

Codecov / codecov/patch

superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts#L226

Added line #L226 was not covered by tests
const series: SeriesOption[] = [];
const formatter = contributionMode
? getNumberFormatter(',.0%')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Loading