1
我想用Android的GraphView庫,當我嘗試這個系列我有錯,請幫忙爲什麼圖表不能被延伸 我的系列這樣的代碼來繪製X,Y的情節:的Android graphview x值比前值低
double[] series1Numbers = {0.07, 0.066, 0.069, 0.077, 0.090, 0.106, 0.123, 0.142, 0.161, 0.180, 0.200 };
double[] series2Numbers = {0.08, 0.078, 0.094, 0.101, 0.108, 0.115, 0.122, 0.129, 0.136, 0.143, 0.150};
for (int i = 0; i < series1Numbers.length; i++){
series.appendData(new DataPoint(series2Numbers[i], series1Numbers[i]), true, 20);
Log.d("x,y : ", String.valueOf(series1Numbers[i]) + ", " + String.valueOf(series2Numbers[i]));
}
graph.addSeries(series);
這裏是我的錯誤:
11-20 02:56:45.285 18818-18818/com.example.fetimeh.timol E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.fetimeh.timol, PID: 18818
java.lang.IllegalArgumentException: new x-value must be greater then the last value. x-values has to be ordered in ASC.
at com.jjoe64.graphview.series.BaseSeries.appendData(BaseSeries.java:411)
at com.jjoe64.graphview.series.LineGraphSeries.appendData(LineGraphSeries.java:646)
at com.jjoe64.graphview.series.BaseSeries.appendData(BaseSeries.java:464)
at com.example.fetimeh.timol.calc.tidakadakorelasi$1.onClick(tidakadakorelasi.java:126)
at android.view.View.performClick(View.java:4757)
at android.view.View$PerformClick.run(View.java:19757)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5219)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
_new x值必須大於最後一個值。 x值已經在ASC_ 責令只是排序從最小值你的陣列最高 – aleksandrbel
如果我對它進行排序的結果將是不同的,有什麼選擇? – montblanc