0

我正在尝试从两个不同的数组中获取数据,并将其存储在 graphview 数据点中,并使用下面的给定代码。虽然来自 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);
}
4

0 回答 0