SciChart provides a clean and simple API to transform pixels to data-values and vice versa via the IAxisCore.getDataValue() and IAxisCore.getCoordinate() methods.
Where Pixel Coordinates are measured from
It is important to note when converting Pixels to Data Coordinates and vice versa that pixels are measured from the top-left inside corner of the chart. So, the pixel coordinate (0,0) corresponds to the data-value at (XAxis.getVisibleRange().getMin(), YAxis.getVisibleRange().getMax()), and the pixel coordinate (Width, Height) corresponds to the data-value at (XAxis.getVisibleRange().getMax(), YAxis.getVisibleRange().getMin()),
Converting between Pixels and Data Coordinates
Data-values are converted to pixel coordinates via the IAxisCore.getCoordinate() method. Also, Coordinates in pixels are converted back to chart data-values via the IAxisCore.getDataValue() method. It expects a coordinate in pixels and returns the closest data value to that coordinate.
You can find some examples how to do the conversions below.
Converting NumericAxis Data to Pixels
Converting DateAxis Data to/from Pixels
Converting CategoryDateAxis Data to/from Pixels
CategoryDateAxis is slightly different. The getCoordinate() method expects an integer, which is the index of a data point inside a DataSeries. You can convert Date to index and vice versa through the ICategoryLabelProvider as follows:
Transforming Pixels to the Inner Viewport
If you subscribe to listen to touch events on a SciChartSurface, the touch coordinates you will receive will be relative to the SciChartSurface itself. Before the Coordinate Transformation API can be used, it's important to ensure that such coordinates are transformed relative to the viewport (the central area). The view to translate relative to can be obtained calling either the ISciChartSurface.getModifierSurface() or ISciChartSurface.getRenderableSeriesArea(), depending on the context. By default, both occupy the same area, but this can be changed if a custom LayoutManager is provided:
The transformation can be done via the ISciChartSurface.translatePoint() method:
For more information on chart layout customization, please refer to the Placing Axes Central in the Chart article.