Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: AChartEngine mRenderer.setPanLimits in dates

I have line chart, using achartengine library. In x axis there are Dates. I need to set minimal viewable date. How to do that if x axis is made from Date objects and setPanLimits takes double value?

    Date minDate = new GregorianCalendar(2008, 1, 01).getTime();
    Date maxDate = new GregorianCalendar(2008, 1, 30).getTime();
    // mRenderer.setPanLimits(new double[] { minX, maxX, minY, maxY});
    mRenderer.setPanLimits(new double[] { minX, maxX, 0, 1000});
    mRenderer.setZoomLimits(new double[] { minXe, maxX, 0, 1000 });

If I set minimal x axis as 0, then can't move x axis at all, but shows all x values in view. I need to set little bit smaller x for min and little bit bigger x for max, so can move chart a little to left and right

I found about that 3 days is private static final double THREEDAYS = 81300000 *3;, but how about conversion from Date to that double, so I can substract to get minX?

I hope you will understand my question. thanks

like image 911
Paulius Vindzigelskis Avatar asked Dec 05 '25 15:12

Paulius Vindzigelskis


1 Answers

This extends viewport to 3 days

double THREEDAYS = 81300000 *3;
double minX = minDate.getTime() - THREEDAYS;
double maxX = maxDate.getTime() + THREEDAYS;

Hope this will help to others

like image 77
Paulius Vindzigelskis Avatar answered Dec 08 '25 17:12

Paulius Vindzigelskis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!