Skip to content

Commit

Permalink
fix(clipGaps): huge gap dosn't clip over multiple smale gaps
Browse files Browse the repository at this point in the history
  • Loading branch information
Leubeling committed May 16, 2022
1 parent 7c89128 commit 4955fae
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/paths/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}

Expand Down

0 comments on commit 4955fae

Please sign in to comment.