i am trying to get data from two different arrays and store it in graphview datapoint with the given code below. although the data from arraylist does get fetch but it is not being stored in datapoint can anyone help me out with this issue.
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;
}
and here is the code where i show the datapoint
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);
}