
iOS & macOS Charting Documentation - SciChart iOS & macOS Charts SDK v4.x
Axis 3D APIs - Convert World to Data coordinates
SciChart iOS 3D provides a clean and simple API to transform 3D world coordinates to data-values and vice versa via the ISCIAxisCore.currentCoordinateCalculator
API. The ISCICoordinateCalculator
has the following methods suitable for conversions:
-[ISCICoordinateCalculator getCoordinateFrom:]
- expects a double representation ofdata-value
and returns the corresponding pixel coordinate.-[ISCICoordinateCalculator getDataValueFrom:]
- expects acoordinate in pixels
and returns the closest data value to that coordinate (represented in double).
NOTE: For more information about
ISCICoordinateCalculator
- please read the Axis APIs - Convert Pixel to Data coordinates article.
All Axes are responsible for converting between data-values and world-coordinates:
X-Axis
converts X data-values to X-World coordinates.Y-Axis
converts Y data-values to Y-world coordinates.Z-Axis
converts Z-data values to Z-world coordinates.
NOTE: For more information about the World Coordinates and Data Coordinates - please see the corresponding sections in the Coordinates in 3D Space article.
Getting a CoordinateCalculator instance
There is a ISCIAxisCore.currentCoordinateCalculator
property, which is readonly
, and which provides a coordinate calculator instance which is only valid for the current render pass.
NOTE: If the
ISCIAxisCore.visibleRange
changes, theISCIChartSurface3D.worldDimensions
changes or the data changes - then theISCICoordinateCalculator
will be recreated under the hood, so it might give incorrect results. Hence, it’s advisable not to cache CoordinateCalculator instance, or cache it only for a short period of time, e.g. when using inside a loop.
Converting between World to Data Coordinates
As mentioned above - data-values are converted to world coordinates via the -[ISCICoordinateCalculator getCoordinateFrom:]
method. Also, Coordinates in pixels are converted back to chart data-values via the -[ISCICoordinateCalculator getDataValueFrom:]
method.
Also, you might guess, converting World to Data-Coordinates and vice versa slightly differs for different axis types due to difference in underlying data-types. In particular the following ones:
Read on to get better understanding of such conversions.
SCINumericAxis3D conversions
The simplest case is the SCINumericAxis3D
. ISCICoordinateCalculator
for NumericAxis 3D works the data-value as double. So let’s take our Scatter Chart 3D example, and try do some conversions
NOTE: The exact data-values and coordinates might differ depending on your visibleRange, viewport etc…
SCIDateAxis3D conversions
Similarly to SCINumericAxis3D
- the SCIDateAxis3D
is quite simple with one difference - it’s ISCICoordinateCalculator
works with double representation of Date, which is timeIntervalSince1970. So let’s take our Date Axis 3D as an example, and try do some conversions.
NOTE: Since the
ISCICoordinateCalculator
works with double representation of Date intimeIntervalSince1970
, you will need to do all the needed conversions on your own. See the code below:
NOTE: The exact data-values and coordinates might differ depending on your visibleRange, viewport etc…