Linuxkey007 / achartengine

Automatically exported from code.google.com/p/achartengine
0 stars 0 forks source link

index out of bound #220

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi, there is a problem with adding points back in time, I have background task 
and it try to add point back in time (for example, if we have 10:50:00 it adds 
10:50:01), after adding few values it crashes, and logcat says:

06-06 14:38:14.629: W/dalvikvm(4397): threadid=1: thread exiting with uncaught 
exception (group=0x409d81f8)
06-06 14:38:14.649: E/AndroidRuntime(4397): FATAL EXCEPTION: main
06-06 14:38:14.649: E/AndroidRuntime(4397): 
java.lang.IndexOutOfBoundsException: Invalid index 45, size is 37
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
java.util.ArrayList.get(ArrayList.java:304)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
org.achartengine.util.IndexXYMap.getYByIndex(IndexXYMap.java:80)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
org.achartengine.model.XYSeries.getY(XYSeries.java:169)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
org.achartengine.chart.XYChart.drawChartValuesText(XYChart.java:551)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
org.achartengine.chart.XYChart.drawSeries(XYChart.java:502)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
org.achartengine.chart.XYChart.draw(XYChart.java:286)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
org.achartengine.GraphicalView.onDraw(GraphicalView.java:166)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
android.view.View.draw(View.java:10982)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
android.view.ViewGroup.drawChild(ViewGroup.java:2887)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
android.view.ViewGroup.drawChild(ViewGroup.java:2885)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
android.view.ViewGroup.drawChild(ViewGroup.java:2885)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
android.view.ViewGroup.drawChild(ViewGroup.java:2885)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
android.view.ViewGroup.drawChild(ViewGroup.java:2885)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
android.view.View.draw(View.java:10985)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
android.widget.FrameLayout.draw(FrameLayout.java:450)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:212
6)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
android.view.ViewRootImpl.draw(ViewRootImpl.java:2030)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1638)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2446)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
android.os.Handler.dispatchMessage(Handler.java:99)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
android.os.Looper.loop(Looper.java:137)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
android.app.ActivityThread.main(ActivityThread.java:4424)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
java.lang.reflect.Method.invokeNative(Native Method)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
java.lang.reflect.Method.invoke(Method.java:511)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-06 14:38:14.649: E/AndroidRuntime(4397):     at 
dalvik.system.NativeStart.main(Native Method)

If you want i can place code but is as simple as it can. After drawing chart it 
only use in background "series.add(date, value);" and after that "repaint"

Original issue reported on code.google.com by wsinfgru...@gmail.com on 11 Jun 2012 at 7:52

GoogleCodeExporter commented 9 years ago
The contents of the series must be sorted ascending. So, if you add new data, 
make sure you insert it where it needs to be such as values are sorted.

Original comment by dandrome...@gmail.com on 13 Jun 2012 at 10:45