Alok Alok - 1 year ago 118
Android Question

MpAndroid CandleStick Chart, to see the last values

I am using MPAndroid Chart Library's Candle Stick Chart.
like i am showing financial data from year 2011 tills date for every 10 minutes.
so i have lots of candle data in one screen.
i have zoomed in the values using
candleStickChart.setVisibleYRangeMaximum(10, YAxis.AxisDependency.RIGHT);
candleStickChart.setScaleMinima(150f, 1.5f);

but i have to scroll to right to see the last candle data.
i have gone through the documentations, but not able to get how to fix the screen to latest data to swipe to left to see the previous

Answer Source

Try with this:

mChart.moveViewToX(xVals.size());
//Here mChart is your chart object and xVals contains values of X axis.

This answer will solve your problem.

Edit 1:

mChart.setVisibleXRangeMinimum(7);
mChart.setVisibleXRangeMaximum(7);

This will show maximum and minimum 7 candles in screen at a time. To view more you have to swipe.