How to get the currently visible x- and y-axis range using MPAndroidChart?

I am creating a chart using the MPAndroidChart library . I see chart.getLowestVisibleXIndex()and methods chart.getHighestVisibleXIndex()to get the current visible range on the x axis.

But I also need to get the visible range of the Y axis. Is this possible, and if so, how can I do this?

+4
source share
1 answer

Yes, there is a pretty simple way to do this. All you need is an instance of your chart and ViewPortHandler.

ViewPortHandler contains information about the current borders of the chart and the drawing area.

ViewPortHandler handler = mChart.getViewPortHandler();

PointD topLeft = mChart.getValuesByTouchPoint(handler.contentLeft(), handler.contentTop(), YAxis.AxisDependency.LEFT);
PointD bottomRight = mChart.getValuesByTouchPoint(handler.contentRight(), handler.contentBottom(), YAxis.AxisDependency.LEFT);

topLeft x y, bottomRight x y.

AxisDependency , ( , , YAxis).

+3

Source: https://habr.com/ru/post/1629332/


All Articles