Pre loader

Getting Y coordinate from data



How can i convert my data to Y coordinate value in OhlsSeries?

Please advise. Thanks.

  • You must to post comments

Hi Artem

You can convert between Data and Pixel coordinates in SciChart.js using this API

Axis APIs – Convert Pixel to Data Coordinates

If you have the data-value for the series, pass it to the YAxis coordinate calculator to do the conversion, like this:

const yAxis = sciChartSurface.xAxes.get(0); // Type AxisBase2D
const coordCalc = yAxis.getCurrentCoordinateCalculator(); // Type CoordinateCalculatorBase
// Gets the pixel coordinate relative to viewRect for data-value 1.23 on this axis only
const coord = coordCalc.getCoordinate(1.23);

// Converts a pixel coordinate back to dataValue
const dataValue= coordCalc.getDataValue(coord);

// dataValue should === 1.23

For the x-Axis there is a slightly different approach needed if you are using CategoryAxis. This is covered in the KB article linked above.

Finally, please ensure you understand where coordinates are measured from, also covered in the article above.

enter image description here

There is a note in the docs about how to convert between the inner and outer canvas / viewrect in case you need it.

enter image description here

Best regards,

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies