How can I obtain the corresponding x-axis value (xIndex) of a pixel point in a ScatterChart?
I have been looking through the source code of the library and I think t
Using MPAndroidChart 3.0.1
I think the method you want is:
public MPPointD getValuesByTouchPoint(float x, float y);
Here's a snip from the javadoc:
/**
* Returns a recyclable MPPointD instance.
* returns the x and y values in the chart at the given touch point
* (encapsulated in a MPPointD). This method transforms pixel coordinates to
* coordinates / values in the chart. This is the opposite method to
* getPixelsForValues(...).
To use it in your app, do something like this:
MPPointD point = mChart.getTransformer(AxisDependency.LEFT).getValuesByTouchPoint(x,y);
double xValue = point.x;
double yValue = point.y;
The parameters passed into the method (float x, float y)
are your pixel co-ordinates that you want to be converted into x and y values in your chart.