achartengine泡沫图泛问题

时间:2013-09-20 13:59:53

标签: android achartengine

我在achartengine中有一个气泡图。我有XYMultipleSeriesRenderer,我添加了XYValueSeries,并绘制了几个点。我有X轴和Y轴的自定义标签。问题是当我们将所有点一起显示时,标签太小了。所以我做的是设置setXAxisMax(10)setYAxisMax(10),以便在轴上一次显示10个点。但是,如果您平移并移动应用程序崩溃,则例外:

09-20 09:56:11.427: E/AndroidRuntime(3041): java.lang.ArrayIndexOutOfBoundsException: length=202; index=-51
09-20 09:56:11.427: E/AndroidRuntime(3041):     at java.util.ArrayList.get(ArrayList.java:310)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at org.achartengine.model.XYValueSeries.getValue(XYValueSeries.java:118)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at org.achartengine.chart.BubbleChart.drawSeries(BubbleChart.java:78)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at org.achartengine.chart.XYChart.drawSeries(XYChart.java:540)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at org.achartengine.chart.XYChart.draw(XYChart.java:320)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at org.achartengine.GraphicalView.onDraw(GraphicalView.java:181)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.view.View.draw(View.java:13944)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.view.View.draw(View.java:13825)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.view.ViewGroup.drawChild(ViewGroup.java:3083)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2920)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.view.View.draw(View.java:13823)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.view.ViewGroup.drawChild(ViewGroup.java:3083)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2920)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.view.View.draw(View.java:13823)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.view.ViewGroup.drawChild(ViewGroup.java:3083)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2920)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.view.View.draw(View.java:13823)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.view.ViewGroup.drawChild(ViewGroup.java:3083)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2920)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.view.View.draw(View.java:13823)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.view.ViewGroup.drawChild(ViewGroup.java:3083)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2920)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.view.View.draw(View.java:13947)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.widget.FrameLayout.draw(FrameLayout.java:467)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2224)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.view.ViewRootImpl.drawSoftware(ViewRootImpl.java:2482)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.view.ViewRootImpl.draw(ViewRootImpl.java:2395)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2239)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1872)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1004)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5481)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.view.Choreographer.doCallbacks(Choreographer.java:562)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.view.Choreographer.doFrame(Choreographer.java:532)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.os.Handler.handleCallback(Handler.java:730)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.os.Handler.dispatchMessage(Handler.java:92)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.os.Looper.loop(Looper.java:137)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at android.app.ActivityThread.main(ActivityThread.java:5103)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at java.lang.reflect.Method.invokeNative(Native Method)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at java.lang.reflect.Method.invoke(Method.java:525)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-20 09:56:11.427: E/AndroidRuntime(3041):     at dalvik.system.NativeStart.main(Native Method)

请让我知道可能是什么问题

1 个答案:

答案 0 :(得分:2)

这是我自己的代码的问题。 X值需要以递增方式添加到XYValueSeries,即如果添加5,则以后不能再添加4等X值。所以我解析JSON然后根据X值对集合进行排序,然后按顺序将它们添加到系列中。