From c829d87eae12a3bdc23425a1953541f056b62cb0 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Tue, 11 Mar 2025 08:16:04 +0100 Subject: [PATCH] eq/plot: smoother curves --- CHANGELOG.md | 1 + src/client/widgets/graphs/plot.js | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 124189f9..808c23f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - eq: adapt sampling frequency to the x-axis range - xy/multixy: add `auto` choice to to `axisLock` (locks on the first moved axis) - file: `extension` can now be an array of strings + - plot/eq: smoother curves ## 1.27.5 diff --git a/src/client/widgets/graphs/plot.js b/src/client/widgets/graphs/plot.js index 58e9dd87..98587bde 100644 --- a/src/client/widgets/graphs/plot.js +++ b/src/client/widgets/graphs/plot.js @@ -123,22 +123,21 @@ module.exports = class Plot extends StaticProperties(Canvas, {bypass: true, inte var points = [], padding = this.cssVars.padding + this.cssVars.lineWidth, - decimals = this.getProp('smooth') ? 1 : 0, length = this.value.length, x, y, i, previousValue, nx, ny for (i = 0; i < length; i++) { if (this.value[i].length) { - points.push(mapToScale(this.value[i][0], [this.rangeX.min, this.rangeX.max], [padding, this.width - padding], decimals, this.logScaleX, true)) - points.push(mapToScale(this.value[i][1], [this.rangeY.min, this.rangeY.max], [this.height - 2 * PXSCALE - padding, 2 * PXSCALE + padding], decimals, this.logScaleY, true)) + points.push(mapToScale(this.value[i][0], [this.rangeX.min, this.rangeX.max], [padding, this.width - padding], -1, this.logScaleX, true)) + points.push(mapToScale(this.value[i][1], [this.rangeY.min, this.rangeY.max], [this.height - 2 * PXSCALE - padding, 2 * PXSCALE + padding], -1, this.logScaleY, true)) } else { if (i < length - 2 && this.value[i] === previousValue && this.value[i+1] === previousValue) { continue } - nx = mapToScale(i, [0, this.value.length - 1], [padding, this.width - padding], decimals, this.logScaleX, true) - ny = mapToScale(this.value[i], [this.rangeY.min, this.rangeY.max], [this.height - 2 * PXSCALE - padding, 2 * PXSCALE + padding], decimals, this.logScaleY, true) + nx = mapToScale(i, [0, this.value.length - 1], [padding, this.width - padding], -1, this.logScaleX, true) + ny = mapToScale(this.value[i], [this.rangeY.min, this.rangeY.max], [this.height - 2 * PXSCALE - padding, 2 * PXSCALE + padding], -1, this.logScaleY, true) if (x !== nx || y !== ny) { points.push(nx)