From dde09f434c02a0cfc3a7cb62b5c90bb4ff3ded24 Mon Sep 17 00:00:00 2001 From: Andrei Kashcha Date: Tue, 16 Jan 2024 16:25:29 -0800 Subject: [PATCH] fix(bar): Fixing a missing bar in log scaled stack. close 19517 --- src/layout/barGrid.ts | 8 +++++++- test/bar-log.html | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/layout/barGrid.ts b/src/layout/barGrid.ts index 726c084f82..ae8112665d 100644 --- a/src/layout/barGrid.ts +++ b/src/layout/barGrid.ts @@ -545,7 +545,13 @@ export function createProgressiveLayout(seriesType: string): StageHandler { else { const coord = cartesian.dataToPoint([baseValue, value]); if (stacked) { - const startCoord = cartesian.dataToPoint([baseValue, startValue]); + let adjustedStartValue = startValue; + if (startValue === 0 && valueAxis.type === 'log') { + // Since log(0) == -Infinity, we adjust the start value to 1 + // so that log(1) == 0, and the bars go from 0. + adjustedStartValue = 1; + } + const startCoord = cartesian.dataToPoint([baseValue, adjustedStartValue]); baseCoord = startCoord[1]; } x = coord[0] + columnOffset; diff --git a/test/bar-log.html b/test/bar-log.html index 568d57e213..5e872857de 100644 --- a/test/bar-log.html +++ b/test/bar-log.html @@ -40,6 +40,7 @@
+
+ + \ No newline at end of file