Skip to content

Commit

Permalink
fix #3827 - y-axis tooltip value in reversed
Browse files Browse the repository at this point in the history
  • Loading branch information
junedchhipa committed May 7, 2024
1 parent ec962e8 commit 84c2ca8
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/modules/tooltip/AxesTooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,7 @@ class AxesTooltip {
const gl = w.globals
const yAxisSeriesArr = gl.seriesYAxisMap[index]

if (ttCtx.yaxisTooltips[index]
&& yAxisSeriesArr.length > 0
) {
if (ttCtx.yaxisTooltips[index] && yAxisSeriesArr.length > 0) {
const lbFormatter = gl.yLabelFormatters[index]
const elGrid = ttCtx.getElGrid()
const seriesBound = elGrid.getBoundingClientRect()
Expand All @@ -179,14 +177,13 @@ class AxesTooltip {
translationsIndex = seriesIndex
}
const hoverY =
(clientY - seriesBound.top)
* xyRatios.yRatio[translationsIndex]
const height =
gl.maxYArr[seriesIndex]
- gl.minYArr[seriesIndex]
const val =
gl.minYArr[seriesIndex]
+ (height - hoverY)
(clientY - seriesBound.top) * xyRatios.yRatio[translationsIndex]
const height = gl.maxYArr[seriesIndex] - gl.minYArr[seriesIndex]
let val = gl.minYArr[seriesIndex] + (height - hoverY)

if (w.config.yaxis[index].reversed) {
val = gl.maxYArr[seriesIndex] - (height - hoverY)
}

ttCtx.tooltipPosition.moveYCrosshairs(clientY - seriesBound.top)
ttCtx.yaxisTooltipText[index].innerHTML = lbFormatter(val)
Expand Down

0 comments on commit 84c2ca8

Please sign in to comment.