From df91b22cc088153dd59123f0dff3407962793038 Mon Sep 17 00:00:00 2001 From: Nick Krecklow Date: Tue, 9 Jun 2020 22:14:19 -0500 Subject: [PATCH] fix tooltip series selection scaling issue --- assets/js/graph.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/assets/js/graph.js b/assets/js/graph.js index 1f2305b..2681a99 100644 --- a/assets/js/graph.js +++ b/assets/js/graph.js @@ -142,6 +142,8 @@ export class GraphDisplayManager { let closestSeriesIndex = -1 let closestSeriesDist = Number.MAX_VALUE + const plotHeight = this._plotInstance.bbox.height / devicePixelRatio + for (let i = 1; i < this._plotInstance.series.length; i++) { const series = this._plotInstance.series[i] @@ -153,11 +155,9 @@ export class GraphDisplayManager { if (typeof point === 'number') { const scale = this._plotInstance.scales[series.scale] - const posY = (1 - ((point - scale.min) / (scale.max - scale.min))) * this._plotInstance.height + const posY = (1 - ((point - scale.min) / (scale.max - scale.min))) * plotHeight - // +20 to offset some sort of strange calculation bug - // cursor.top does not seem to correctly align with the generated posY values - const dist = Math.abs(posY - (this._plotInstance.cursor.top + 20)) + const dist = Math.abs(posY - this._plotInstance.cursor.top) if (dist < closestSeriesDist) { closestSeriesIndex = i