From 25160d9688ba1c248b7fcf8f13cbd1d98a419615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20M=C3=BCller?= Date: Sat, 27 Jan 2024 17:11:40 +0100 Subject: [PATCH] axis calculation fixed for mix of line and bar charts --- packages/mermaid/src/diagrams/xychart/xychartDb.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/mermaid/src/diagrams/xychart/xychartDb.ts b/packages/mermaid/src/diagrams/xychart/xychartDb.ts index 1af9f777d..bb829eebd 100644 --- a/packages/mermaid/src/diagrams/xychart/xychartDb.ts +++ b/packages/mermaid/src/diagrams/xychart/xychartDb.ts @@ -113,12 +113,13 @@ function setYAxisRangeData(min: number, max: number) { // this function does not set `hasSetYAxis` as there can be multiple data so we should calculate the range accordingly function setYAxisRangeFromPlotData(data: number[], plotType: PlotType) { - dataSets.push(data); - const sum = new Array(data.length).fill(0); - for (let i = 0; i < data.length; i++) { - for (const entry of dataSets) { - sum[i] += entry[i]; + if (plotType === PlotType.BAR) { + dataSets.push(data); + for (let i = 0; i < data.length; i++) { + for (const entry of dataSets) { + sum[i] += entry[i]; + } } }