Skip to content

How can I get a price from y coordinate, where the crosshair points? #1102

Answered by edew
newtilus asked this question in Q&A
Discussion options

You must be logged in to vote

@newtilus

You can use https://tradingview.github.io/lightweight-charts/docs/api/interfaces/ISeriesApi#coordinatetoprice

For example

const series = chart.addLineSeries();
series.setData([ /* some data */ ]);

const myClickHandler = (param) => {
  if (!param.point) {
    return;
  }

  console.log(`The price is ${series.coordinateToPrice(param.point.y)}`);
}

chart.subscribeClick(myClickHandler);

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@newtilus
Comment options

@newtilus
Comment options

Answer selected by newtilus
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants