Way to change price line `HitTestThreshold`

Author: JokeroCreated Jun 1, 2024Updated Jun 5, 2026
Labelshelp wantedgood first issuepolish

Is your feature request related to a problem? Please describe.

This constant defines the area used to check if a price line is hovered over or clicked. The current value (7) is relatively large and causes issues when chart contains several price lines. For example, hovering over one line might unexpectedly return hoveredObjectId with another price line id.

Demo https://codesandbox.io/p/sandbox/lightweight-charts-skeleton-forked-v6tqm6.

Steps to reproduce:

  1. open console
  2. reload page with chart
  3. hover over black price line
  4. notice that hoveredObjectId contains red price line id
image

Maybe the idea of having large number for HitTestThreshold was to have better user experience in mobile browsers (so you don't need to tap precisely on the thin line). However, in a desktop browser, it looks more like a bug.

Describe the solution you'd like

The simplest solution is to allow to configure a value for the threshold that is currently hardcoded in HitTestThreshold constant.

For example, for a scenario where charts are used only in desktop browsers, I would disable the threshold at all (i.e. set it to zero).

Source: tradingview/lightweight-charts