From 98d7c6116bdaad8a4f1b28a64f9d7ba4150afd89 Mon Sep 17 00:00:00 2001 From: Ross Johnson <159597299+rosco54@users.noreply.github.com> Date: Thu, 19 Sep 2024 17:38:27 +1000 Subject: [PATCH] Remove unused variable (tidy-up, unrelated to the main issue) Issue 4686 Explicitly check for single isolated points when creating paths for 'straight' and 'smooth' curves. Curve type 'monotoneCubic' already does this intrinsically due to the different algorithm employed. --- src/charts/Line.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/charts/Line.js b/src/charts/Line.js index 319233b82..6861e23f3 100644 --- a/src/charts/Line.js +++ b/src/charts/Line.js @@ -794,7 +794,6 @@ class Line { curve, isRangeStart, }) { - let w = this.w let graphics = new Graphics(this.ctx) const areaBottomY = this.areaBottomY let rangeArea = type === 'rangeArea' @@ -952,11 +951,26 @@ class Line { } areaPath = graphics.move(pX, pY) + // Check for single point + if (series[i][j + 1] === null) { + linePath += graphics.line(pX, pY); + areaPath += graphics.line(pX, pY); + linePaths.push(linePath); + areaPaths.push(areaPath); + // Stay in pathState = 0; + break + } pathState = 1 if (j < series[i].length - 2) { let p = graphics.curve(pX + length, pY, x - length, y, x, y) linePath += p areaPath += p + // Check for single point + if (series[i][j + 1] === null) { + linePaths.push(linePath) + areaPaths.push(areaPath) + pathState = 0 + } break } // Continue on with pathState 1 to finish the path and exit @@ -1034,6 +1048,15 @@ class Line { } areaPath = graphics.move(pX, pY) + // Check for single point + if (series[i][j + 1] === null) { + linePath += graphics.line(pX, pY); + areaPath += graphics.line(pX, pY); + linePaths.push(linePath); + areaPaths.push(areaPath); + // Stay in pathState = 0 + break + } pathState = 1 if (j < series[i].length - 2) { let p = pathToPoint(curve, x, y)