Android GraphView Library - Zoom and scroll not working in small X increments (seconds)
I am using the GraphView library (see https://github.com/jjoe64/GraphView or http://www.jjoe64.com/p/graphview-library.html ). Working with GraphView-Demos-master, I am modifying the "public DateAsXAxis .." class to slightly increment the date in seconds rather than days. Scaling and scrolling do not work with seconds increments in the X-axis.
Calendar calendar = Calendar.getInstance();
Date d1 = calendar.getTime();
DataPoint[] datos = new DataPoint[50];
for (int i=0; i<50; i++){
datos[i]= new DataPoint(d1,i%4);
// d1.setTime(d1.getTime() + 86400000); // 1 day works ok, but with some jumps in scale
d1.setTime(d1.getTime() + 60000); // 1 min doesn't work scrolling not scaling.
}
LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>(datos);
graph.addSeries(series);
// set date label formatter
graph.getGridLabelRenderer().setLabelFormatter(new DateAsXAxisLabelFormatter(getActivity()));
graph.getGridLabelRenderer().setNumHorizontalLabels(3); // only 4 because of the space
// set manual x bounds to have nice steps
graph.getViewport().setMinX(datos[0].getX());
graph.getViewport().setMaxX(datos[3].getX());
graph.getViewport().setXAxisBoundsManual(true);
graph.getViewport().setScalable(true);
+3
source to share
No one has answered this question yet
Check out similar questions: