我正在尝试从两个不同的数组中获取数据并将其存储在graphview数据点中,并使用下面的给定代码。 虽然来自arraylist的数据确实可以获取,但它没有存储在datapoint中,任何人都可以帮助我解决这个问题。
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);
}