2014-09-01 61 views
0

4統籌GraphView我在如何顯示在Android的

GraphViewSeries exampleSeries = new GraphViewSeries(new GraphViewData[] { 
     new GraphViewData(1, 2.0d) 
     , new GraphViewData(2, -1.5d) 
     , new GraphViewData(-3, 2.5d) 
     , new GraphViewData(-4, -1.0d) 
    }); 

    GraphView graphView = new LineGraphView(
     this // context 
     , "GraphView" // heading 
    ); 
    graphView.addSeries(exampleSeries); // data 
    graphView.getGraphViewStyle().setNumHorizontalLabels(5); 
    graphView.getGraphViewStyle().setNumVerticalLabels(5); 
    //graphView.getGraphViewStyle().setVerticalLabelsWidth(300); 
    graphView.setManualYAxisBounds(5,1); 


    LinearLayout layout = (LinearLayout) findViewById(R.id.layout); 
    layout.addView(graphView); 

得到錯誤我想提請所有四個座標線..但負分不工作.. 幫助我

iwant這樣

堆棧跟蹤

09-01 04:17:53.299: I/Process(2263): Sending signal. PID: 2263 SIG: 9 
09-01 04:17:54.149: D/AndroidRuntime(2302): Shutting down VM 
09-01 04:17:54.149: W/dalvikvm(2302): threadid=1: thread exiting with uncaught exception (group=0xb3afcba8) 
09-01 04:17:54.169: E/AndroidRuntime(2302): FATAL EXCEPTION: main 
09-01 04:17:54.169: E/AndroidRuntime(2302): Process: com.jsk.simplegraph, PID: 2302 
09-01 04:17:54.169: E/AndroidRuntime(2302): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.jsk.simplegraph/com.jsk.simplegraph.SimpleGraphMainActivity}: java.lang.IllegalArgumentException: The order of the values is not correct. X-Values have to be ordered ASC. First the lowest x value and at least the highest x value. 
09-01 04:17:54.169: E/AndroidRuntime(2302):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195) 
09-01 04:17:54.169: E/AndroidRuntime(2302):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
09-01 04:17:54.169: E/AndroidRuntime(2302):  at android.app.ActivityThread.access$800(ActivityThread.java:135) 
09-01 04:17:54.169: E/AndroidRuntime(2302):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
09-01 04:17:54.169: E/AndroidRuntime(2302):  at android.os.Handler.dispatchMessage(Handler.java:102) 
09-01 04:17:54.169: E/AndroidRuntime(2302):  at android.os.Looper.loop(Looper.java:136) 
09-01 04:17:54.169: E/AndroidRuntime(2302):  at android.app.ActivityThread.main(ActivityThread.java:5017) 
09-01 04:17:54.169: E/AndroidRuntime(2302):  at java.lang.reflect.Method.invokeNative(Native Method) 
09-01 04:17:54.169: E/AndroidRuntime(2302):  at java.lang.reflect.Method.invoke(Method.java:515) 
09-01 04:17:54.169: E/AndroidRuntime(2302):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
09-01 04:17:54.169: E/AndroidRuntime(2302):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
09-01 04:17:54.169: E/AndroidRuntime(2302):  at dalvik.system.NativeStart.main(Native Method) 
09-01 04:17:54.169: E/AndroidRuntime(2302): Caused by: java.lang.IllegalArgumentException: The order of the values is not correct. X-Values have to be ordered ASC. First the lowest x value and at least the highest x value. 
09-01 04:17:54.169: E/AndroidRuntime(2302):  at com.jjoe64.graphview.GraphViewSeries.checkValueOrder(GraphViewSeries.java:200) 
09-01 04:17:54.169: E/AndroidRuntime(2302):  at com.jjoe64.graphview.GraphViewSeries.<init>(GraphViewSeries.java:74) 
+0

請發佈堆棧跟蹤。 – 2014-09-01 08:02:09

+0

我無法理解你的問題 – 2014-09-01 08:11:50

+1

[可惜MyApp已停止。我怎樣才能解決這個問題?](http://stackoverflow.com/questions/23353173/uncomfort-myapp-has-stopped-how-can-i-solve-this) – 2014-09-01 08:12:40

回答

0

您的堆棧信息是很清楚的:

The order of the values is not correct. X-Values have to be ordered ASC. First the lowest x value and at least the highest x value. 

所以,你應該初始化exampleSeries方式如下:

GraphViewSeries exampleSeries = new GraphViewSeries(new GraphViewData[] { 
    new GraphViewData(-4, -1.0d), 
    new GraphViewData(-3, 2.5d), 
    new GraphViewData(1, 2.0d), 
    new GraphViewData(2, -1.5d) 
}); 
0

閱讀stacktr王牌

09-01 04:17:54.169: E/AndroidRuntime(2302): Caused by: java.lang.IllegalArgumentException: The order of the values is not correct. X-Values have to be ordered ASC. First the lowest x value and at least the highest x value. 

試試這個

GraphViewSeries exampleSeries = new GraphViewSeries(new GraphViewData[] { 
    new GraphViewData(-4, -1.0d), 
    new GraphViewData(-3, 2.5d), 
    new GraphViewData(2, -1.5d), 
    new GraphViewData(1, 2.0d) 
}); 
+0

謝謝你Mr.Dodge – 2014-09-06 06:17:11

+0

如果我可以幫忙請接受答案:) – Dodge 2014-09-06 12:20:45