ShinobiCharts for android, panning and zooming while appending data


#1

ShinobiCharts 1.1.2 trial version, Nexus 7 2013, Android 4.3

I created an XY chart like this:

ShinobiChart chart = chartFragment.getShinobiChart();

NumberAxis xAxis = new NumberAxis();

xAxis.setDefaultRange(new NumberRange(0.0, 1000.0));

xAxis.setTickMarkClippingModeHigh(TickMark.ClippingMode.TICKS_PERSIST);

xAxis.enableGesturePanning(true);

xAxis.enableGestureZooming(true);

xAxis.enableMomentumPanning(true);

xAxis.enableMomentumZooming(true);

chart.setXAxis(xAxis);

NumberAxis yAxis = new NumberAxis();

yAxis.setDefaultRange(new NumberRange(0.0, 1000.0));

yAxis.enableGesturePanning(true);

yAxis.enableGestureZooming(true);

yAxis.enableMomentumPanning(true);

yAxis.enableMomentumZooming(true);

chart.addYAxis(yAxis);

//  Current

data = new SimpleDataAdapter<Double, Double>();

LineSeries line = new LineSeries();

line.setDataAdapter(data);

chart.addSeries(line);

chart.redrawChart();

and every 100 ms I added a data point into the data adapter.

data.add(new DataPoint<double, double>(time, value));

Appended data points were shown in real time as it comes but I could not zoom and pan the graph because every time a data point is added it bounces the graph into the original position and original size.

Is there anything I can do for this to enable panning and zooming while adding data in real time?


#2

Hi junggun_lim,

I think what you may be looking for is Axis.setCurrentDisplayedRangePreservedOnUpdate(true). This sets whether the current visible range is preserved when new data comes into the chart. If you set this false the range will reset to the data range, or the default range if you have one, when data is added. If you set this true, the current visible range will not change when new data is added.

Best regards,

Robin Sillem


#3

Now I can make it work! Thank you!

Jung-gun