以下のコードを使用して、2 つの異なる配列からデータを取得し、グラフビュー データポイントに格納しようとしています。arraylist からのデータはフェッチされますが、データポイントに保存されていませんが、誰でもこの問題を解決できます。
public DataPoint[] data() {
int n = listdatatime.size(); //to find out the no. of data-points
DataPoint[] values = new DataPoint[n]; //creating an object of type DataPoint[] of size 'n'
for (int i = 0; i < n; i++) {
try {
DataPoint v = new DataPoint(Math.round(Double.parseDouble(listdatatime.get(i/100*60))), Double.parseDouble(listdataprice.get(i)));
values[i] = v;
} catch (Exception e) {
Toast.makeText(getActivity(), "entry error", Toast.LENGTH_LONG).show();
}
}
Toast.makeText(getActivity(), "" + values, Toast.LENGTH_SHORT).show();
return values;
}
ここにデータポイントを表示するコードがあります
public void addgraph(View view) {
GraphView graph;
PointsGraphSeries<DataPoint> series; //an Object of the PointsGraphSeries for plotting scatter graphs
graph = (GraphView) view.findViewById(R.id.graph);
series = new PointsGraphSeries<>(data()); //initializing/defining series to get the data from the method 'data()'
graph.addSeries(series); //adding the series to the GraphView
series.setShape(PointsGraphSeries.Shape.POINT);
series.setSize(5);
}