Skip to content
Snippets Groups Projects
Unverified Commit 98dbf5ca authored by metabase-bot[bot]'s avatar metabase-bot[bot] Committed by GitHub
Browse files

fix normalized chart crashes when trend lines enabled but there is no insights...

fix normalized chart crashes when trend lines enabled but there is no insights data (#40624) (#40627)

Co-authored-by: default avatarAleksandr Lesnenko <alxnddr@users.noreply.github.com>
parent 7c1f7b77
No related branches found
No related tags found
No related merge requests found
......@@ -33,6 +33,9 @@ function computeExpression(node, x) {
const msToDays = ms => ms / (24 * 60 * 60 * 1000);
export function getNormalizedStackedTrendDatas(trendDatas) {
if (trendDatas.length === 0) {
return [];
}
const count = trendDatas[0].length;
const sums = _.range(count).map(i =>
trendDatas.reduce((sum, trendData) => sum + trendData[i][1], 0),
......
......@@ -36,4 +36,8 @@ describe("getNormalizedStackedTrendDatas", () => {
]),
]);
});
it("should return an empty array when there is no trend data", () => {
expect(getNormalizedStackedTrendDatas([])).toStrictEqual([]);
});
});
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