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

Fix line charts with missing values and duplicate X (#18415)

parent d950c741
No related branches found
No related tags found
No related merge requests found
......@@ -22,9 +22,20 @@ function fillMissingValues(rows, xValues, fillValue, getKey = v => v) {
const fillValues = rows[0].slice(1).map(d => fillValue);
const map = new Map();
for (const row of rows) {
map.set(getKey(row[0]), row);
const key = getKey(row[0]);
const oldRow = map.get(key);
if (oldRow) {
const newRow = row.map((_, i) => row[i] ?? oldRow[i]);
newRow._origin = row._origin;
map.set(key, newRow);
} else {
map.set(key, row);
}
}
const newRows = xValues.map(value => {
const key = getKey(value);
const row = map.get(key);
......
......@@ -159,4 +159,46 @@ describe("visual tests > visualizations > line", () => {
cy.percySnapshot();
});
it("with missing values and duplicate x (metabase#11076)", () => {
visitQuestionAdhoc({
dataset_query: {
type: "native",
native: {
query: `
SELECT CAST('2010-10-01' AS DATE) as d, null as v1, 1 as v2
UNION ALL
SELECT CAST('2010-10-01' AS DATE), 2, null
UNION ALL
SELECT CAST('2010-10-02' AS DATE), 3, null
UNION ALL
SELECT CAST('2010-10-02' AS DATE), null, 4
UNION ALL
SELECT CAST('2010-10-03' AS DATE), null, 5
UNION ALL
SELECT CAST('2010-10-03' AS DATE), 6, null
`,
},
database: 1,
},
display: "line",
visualization_settings: {
"graph.dimensions": ["D"],
"graph.show_values": true,
"graph.metrics": ["V1", "V2"],
series_settings: {
V1: {
"line.missing": "zero",
},
V2: {
"line.missing": "none",
},
},
},
});
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