yunjianwu / achartengine

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

XYChart IndexOutOfBoundsException when use setDisplayChartValues(true) #329

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Steps

1. Create an 2 XYSeries.
2. On SeriesRenderer call setDisplayChartValues(true)
3. ChartView build as CombinedXYChartView (Type of charts are LineChart)

It should show the values of the points, but instead of this I get 
IndexOutOfBoundsException.

I debugged the code, and found the error here (I put if (startIndex + k / 2 < 
itemCount quick fix into the code)

final int itemCount = series.getItemCount();

if (startIndex + k / 2 < itemCount) {
   drawText(canvas, getLabel(renderer.getChartValuesFormat(),               
   series.getY(startIndex + k / 2)), points.get(k), points.get(k + 1) -    
   renderer.getChartValuesSpacing(), paint, 0);
}

In my case the current series has 5 y values, but series.getY is called on 
index 5 and 6 too.

Version of library: 1.0.0 to find error in the source, but I've got the same 
exception when I used 1.1.0 binary.

Original issue reported on code.google.com by bara.bel...@gmail.com on 12 Jul 2013 at 7:50

GoogleCodeExporter commented 9 years ago
I need more explanations on this one.

Original comment by dandrome...@gmail.com on 31 Oct 2013 at 8:36

GoogleCodeExporter commented 9 years ago
I meet the same problem,this is the log:

FATAL EXCEPTION: main
java.lang.IndexOutOfBoundsException: Invalid index 12, size is 12
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
at java.util.ArrayList.get(ArrayList.java:304)
at org.achartengine.util.IndexXYMap.getYByIndex(IndexXYMap.java:86)
at org.achartengine.model.XYSeries.getY(XYSeries.java:203)
at org.achartengine.chart.BarChart.drawChartValuesText(BarChart.java:230)
at org.achartengine.chart.XYChart.drawSeries(XYChart.java:534)
at org.achartengine.chart.CombinedXYChart.drawSeries(CombinedXYChart.java:140)
at org.achartengine.chart.XYChart.draw(XYChart.java:311)

Original comment by tofutomy...@gmail.com on 4 Nov 2013 at 1:12

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Do you get this in version 1.2.0?
https://repository-achartengine.forge.cloudbees.com/snapshot/org/achartengine/ac
hartengine/1.2.0/

Original comment by dandrome...@gmail.com on 7 Jan 2014 at 11:20

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Meet the same problem, even with 1.2.0 version.

01-08 22:26:22.900: E/AndroidRuntime(5068): FATAL EXCEPTION: main
01-08 22:26:22.900: E/AndroidRuntime(5068): 
java.lang.IndexOutOfBoundsException: Invalid index 49, size is 49
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
java.util.ArrayList.get(ArrayList.java:304)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
org.achartengine.util.IndexXYMap.getYByIndex(IndexXYMap.java:86)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
org.achartengine.model.XYSeries.getY(XYSeries.java:225)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
org.achartengine.chart.XYChart.drawChartValuesText(XYChart.java:632)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
org.achartengine.chart.XYChart.drawSeries(XYChart.java:554)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
org.achartengine.chart.XYChart.draw(XYChart.java:322)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
org.achartengine.GraphicalView.onDraw(GraphicalView.java:181)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.View.draw(View.java:13458)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.View.getDisplayList(View.java:12409)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.View.getDisplayList(View.java:12453)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.View.draw(View.java:13182)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.ViewGroup.drawChild(ViewGroup.java:2929)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.View.getDisplayList(View.java:12407)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.View.getDisplayList(View.java:12453)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.View.draw(View.java:13182)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.ViewGroup.drawChild(ViewGroup.java:2929)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.View.getDisplayList(View.java:12407)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.View.getDisplayList(View.java:12453)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.View.draw(View.java:13182)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.ViewGroup.drawChild(ViewGroup.java:2929)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.View.getDisplayList(View.java:12407)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.View.getDisplayList(View.java:12453)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.View.draw(View.java:13182)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.ViewGroup.drawChild(ViewGroup.java:2929)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.View.getDisplayList(View.java:12407)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.View.getDisplayList(View.java:12453)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.View.draw(View.java:13182)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.ViewGroup.drawChild(ViewGroup.java:2929)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.View.getDisplayList(View.java:12407)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.View.getDisplayList(View.java:12453)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.View.draw(View.java:13182)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.ViewGroup.drawChild(ViewGroup.java:2929)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.View.getDisplayList(View.java:12407)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.View.getDisplayList(View.java:12453)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.View.draw(View.java:13182)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.ViewGroup.drawChild(ViewGroup.java:2929)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.View.draw(View.java:13461)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.widget.FrameLayout.draw(FrameLayout.java:467)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:218
3)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.View.getDisplayList(View.java:12409)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.View.getDisplayList(View.java:12453)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1144)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.ViewRootImpl.draw(ViewRootImpl.java:2147)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2019)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1830)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:998)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4212)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.Choreographer.doCallbacks(Choreographer.java:555)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.Choreographer.doFrame(Choreographer.java:525)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.os.Handler.handleCallback(Handler.java:615)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.os.Handler.dispatchMessage(Handler.java:92)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.os.Looper.loop(Looper.java:137)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
android.app.ActivityThread.main(ActivityThread.java:4745)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
java.lang.reflect.Method.invokeNative(Native Method)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
java.lang.reflect.Method.invoke(Method.java:511)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
01-08 22:26:22.900: E/AndroidRuntime(5068):     at 
dalvik.system.NativeStart.main(Nat

Original comment by faniloga...@gmail.com on 8 Jan 2014 at 10:34

GoogleCodeExporter commented 9 years ago

Original comment by 4viewsoft@gmail.com on 9 Jan 2014 at 7:01

GoogleCodeExporter commented 9 years ago
same error 

Original comment by sayyedta...@gmail.com on 24 Jan 2014 at 9:20

GoogleCodeExporter commented 9 years ago
Same here. Only if data have bad sorting on dates/values. Disabling 
setDisplayChartValues(false) result in no crash (but still possible wrong chart 
due to wrong sort of dates, but this of course is fault of the caller, not the 
library). Sometimes crashes on orientation change, I'm investigating on this 
one as well...

Original comment by francesc...@gmail.com on 24 Jan 2014 at 9:25

GoogleCodeExporter commented 9 years ago
Thanks france sir  Your solution has worked for me  .
Error Was wrong sort of dates.

Original comment by sayyedta...@gmail.com on 24 Jan 2014 at 12:15

GoogleCodeExporter commented 9 years ago
Useful info - worked for me - thanks .

Original comment by AivarMer...@gmail.com on 2 Feb 2014 at 12:26

GoogleCodeExporter commented 9 years ago
Thanks for #10's solution. Sort of data does solve my problem.

Original comment by las...@gmail.com on 15 Apr 2014 at 2:57

GoogleCodeExporter commented 9 years ago
same error,Just displayChartValues(false) ,it will be ok

Original comment by zg.y...@gmail.com on 24 Apr 2014 at 8:49

GoogleCodeExporter commented 9 years ago
Meet the same problem,thanks for #10'solution,it,s worked for me.

Original comment by Slisinp...@gmail.com on 28 Aug 2014 at 6:55

GoogleCodeExporter commented 9 years ago
Issue 385 has been merged into this issue.

Original comment by dandrome...@gmail.com on 16 Sep 2014 at 7:20