繁体   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