0

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);
}
  • The statement DataPoint v = new DataPoint(Math.round(Double.parseDouble(listdatatime.get(i/100*60))), Double.parseDouble(listdataprice.get(i))); should be like this DataPoint v = new DataPoint(Math.round(Double.parseDouble(listdatatime.get(i)/100*60)), Double.parseDouble(listdataprice.get(i))); – lib4backer Feb 16 '18 at 06:55
  • First Debug method `data()` make sure data points are filled. If data points are filled then you have watch for calling structure of `GraphView`. – ADM Feb 16 '18 at 06:55
  • let me try then i will updated you guys and thanks for the quick ans – Muhammad Qaseem Feb 16 '18 at 10:07

0 Answers0