From 4955fae4526285edf95490cd35c526e8c24bc266 Mon Sep 17 00:00:00 2001 From: "Leubeling, David" Date: Mon, 16 May 2022 18:10:59 +0200 Subject: [PATCH] fix(clipGaps): huge gap dosn't clip over multiple smale gaps --- src/paths/utils.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/paths/utils.js b/src/paths/utils.js index e2792588..794d8315 100644 --- a/src/paths/utils.js +++ b/src/paths/utils.js @@ -159,13 +159,21 @@ export function clipGaps(gaps, ori, plotLft, plotTop, plotWid, plotHgt) { for (let i = 0; i < gaps.length; i++) { let g = gaps[i]; + // begin gaps always at x=0 + g[0] = Math.max(0, g[0]) + g[1] = Math.max(0, g[1]) + + // do not ignore first gap if less then first Point on chart + if(i===0 && g[0] <= prevGapEnd){ + prevGapEnd = g[1] + } if (g[1] > g[0]) { let w = g[0] - prevGapEnd; w > 0 && rect(clip, prevGapEnd, plotTop, w, plotTop + plotHgt); - prevGapEnd = g[1]; + prevGapEnd = Math.max(prevGapEnd, g[1]); } }