Skip to content

Commit

Permalink
fallback to straight line if the curve goes backwards
Browse files Browse the repository at this point in the history
  • Loading branch information
junedchhipa committed Dec 3, 2023
1 parent 355f9e2 commit 360324f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/libs/monotone-cubic.js
Expand Up @@ -79,10 +79,9 @@ export const svgPath = (points, chartWidth) => {
const pn = prevPoint?.length

if (i > 1 && Math.abs(point[n - 2] - prevPoint[pn - 2]) < chartWidth / 25) {
// fallback to quadratic curve if the x distance is too small
// fallback to straight line if the x distance is too small
// or if the curve goes backward too much
p += `Q${point[0]}, ${point[1]}`
p += `, ${point[2]}, ${point[3]}`
p += `L${point[2]}, ${point[3]}`
} else {
if (n > 4) {
p += `C${point[0]}, ${point[1]}`
Expand Down

0 comments on commit 360324f

Please sign in to comment.