Skip to content
Snippets Groups Projects
Unverified Commit b7a8b429 authored by Alexander Polyankin's avatar Alexander Polyankin Committed by GitHub
Browse files

Fix composite chart layout (#18195)

parent 7e201eaa
No related branches found
No related tags found
No related merge requests found
......@@ -535,12 +535,12 @@ function getCharts(
const { settings, chartType, series, onChangeCardAndRun } = props;
const { yAxisSplit } = yAxisProps;
const isHeterogenous =
_.uniq(series.map(single => getSeriesDisplay(settings, single))).length > 1;
const isHeterogenousOrdinal =
settings["graph.x_axis.scale"] === "ordinal" && isHeterogenous;
const displays = _.uniq(series.map(s => getSeriesDisplay(settings, s)));
const isMixedBar = displays.includes("bar") && displays.length > 1;
const isOrdinal = settings["graph.x_axis.scale"] === "ordinal";
const isMixedOrdinalBar = isMixedBar && isOrdinal;
if (isHeterogenousOrdinal) {
if (isMixedOrdinalBar) {
// HACK: ordinal + mix of line and bar results in uncentered points, shift by
// half the width
parent.on("renderlet.shift", () => {
......@@ -601,7 +601,7 @@ function getCharts(
settings,
seriesChartType,
seriesSettings,
isHeterogenousOrdinal,
isMixedOrdinalBar,
);
return chart;
......
......@@ -118,4 +118,45 @@ describe("visual tests > visualizations > line", () => {
cy.percySnapshot();
});
it("with multiple series and different display types (metabase#11216)", () => {
visitQuestionAdhoc({
dataset_query: {
type: "query",
query: {
"source-table": ORDERS_ID,
aggregation: [["count"], ["sum", ["field", ORDERS.TOTAL, null]]],
breakout: [
[
"field",
ORDERS.CREATED_AT,
{
"temporal-unit": "year",
},
],
],
},
database: 1,
},
display: "line",
visualization_settings: {
series_settings: {
sum: {
display: "line",
},
count: {
display: "area",
},
},
"graph.dimensions": ["CREATED_AT"],
"graph.x_axis.scale": "ordinal",
"graph.show_values": true,
"graph.metrics": ["count", "sum"],
},
});
cy.wait("@dataset");
cy.percySnapshot();
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment