簡體   English   中英

如何在Android中顯示4坐標GraphView

[英]How to display 4 co-ordinate GraphView in 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);

我想為所有四個坐標畫線。但是負點不起作用..幫助我

像這樣

堆棧跟蹤

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)

讀取堆棧跟蹤

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)
});

您的堆棧信息非常清楚:

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)
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM