2017-05-18 5 views
0

私はAndroid ProjectでGraphViewをセットアップしました。残念ながら、私はグラフ上に点の配列をプロットすることはできません。 1つしかプロットしません。Android GraphviewはArrayListからDataPointを1つだけロードします

DayAmountの値は1!3,1,5などです。文字列は1,3などに分割され、x、y座標に変換されます。それはうまく動作します。

なぜループ(generateData)のみがグラフ上に1つのポイントを読み込むように見えるのですか?ここで

は私のグラフの設定です:

GraphView graph = (GraphView) findViewById(R.id.graph); 
 
       mSeries = new LineGraphSeries<>(generateData()); 
 
       StaticLabelsFormatter staticLabelsFormatter = new StaticLabelsFormatter(graph); 
 
    
 
       graph.getGridLabelRenderer().setLabelFormatter(staticLabelsFormatter); 
 
       mSeries.setDrawDataPoints(true); 
 
       graph.addSeries(mSeries); 
 
       graph.getViewport().setMinX(0); 
 
       graph.getViewport().setMaxX(20); 
 
       graph.getViewport().setMinY(0); 
 
       graph.getViewport().setMaxY(20); 
 

 
       graph.getViewport().setYAxisBoundsManual(true); 
 
       graph.getViewport().setXAxisBoundsManual(true);

は、データを生成します。

private DataPoint[] generateData() { 
 
     int size = DayAmount.size(); 
 
     Log.e(TAG, "Size of ARRAY" + size); 
 
     DataPoint[] values = new DataPoint[size]; 
 
     for (int i=0; i < size; i++) { 
 
      String daysAmounts = DayAmount.get(i); 
 

 
      String[] splitthem = daysAmounts.split("!"); 
 

 
      Integer x = Integer.parseInt(splitthem[0]); 
 
      Integer y = Integer.parseInt(splitthem[1]); 
 

 
      Log.e(TAG, "X, Y" + x + " - " + y); 
 

 
      DataPoint v = new DataPoint(x, y); 
 
      values[i] = v; 
 
      Log.e(TAG, "All Values" + v); 
 
     } 
 
     return values; 
 
    }

答えて