From 6dbbc9318d5007eac50f11ce82b989626d84e529 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Tue, 21 Apr 2026 16:42:47 +0200 Subject: [PATCH] plot, eq: unclip line on y axis --- src/client/widgets/graphs/plot.mjs | 4 ++-- src/client/widgets/utils.mjs | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/client/widgets/graphs/plot.mjs b/src/client/widgets/graphs/plot.mjs index 21808f36..6259a00e 100644 --- a/src/client/widgets/graphs/plot.mjs +++ b/src/client/widgets/graphs/plot.mjs @@ -131,14 +131,14 @@ export default class Plot extends StaticProperties(Canvas, {bypass: true}) { if (this.value[i].length) { 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)) + 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, 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], -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) + ny = mapToScale(this.value[i], [this.rangeY.min, this.rangeY.max], [this.height - 2 * PXSCALE - padding, 2 * PXSCALE + padding], -1, this.logScaleY, true, true) if (x !== nx || y !== ny) { points.push(nx) diff --git a/src/client/widgets/utils.mjs b/src/client/widgets/utils.mjs index 9ee90920..62482c86 100644 --- a/src/client/widgets/utils.mjs +++ b/src/client/widgets/utils.mjs @@ -17,10 +17,12 @@ export function clip(value,range) { // decimals: number (-1 to bypass) // log: true, or manual log scale (max log value) // revertLog: boolean -export function mapToScale(value, rangeIn, rangeOut, decimals, log, revertlog) { +export function mapToScale(value, rangeIn, rangeOut, decimals, log, revertlog, noClip) { // clip in - value = clip(value,[rangeIn[0], rangeIn[1]]) + if (!noClip) { + value = clip(value,[rangeIn[0], rangeIn[1]]) + } // normalize @@ -48,7 +50,9 @@ export function mapToScale(value, rangeIn, rangeOut, decimals, log, revertlog) { value = value * (rangeOut[1] - rangeOut[0]) + rangeOut[0] // clip out - value = clip(value, [rangeOut[0], rangeOut[1]]) + if (!noClip) { + value = clip(value, [rangeOut[0], rangeOut[1]]) + } // decimals if (decimals !== -1) value = parseFloat(value.toFixed(decimals))