-1

I am using the graphview library on Android. I need real time / live data. the normal data example works fine, now I want to extend it that on the push of a button I get new data points

    public void onClickButton(View v)
{
    GraphViewData g = new GraphViewData(counter, 7.0d);
    counter = counter + 1;
    exampleSeries.appendData(g, false, 50);

The graph doesn't get updated, the documentation only says I have to use appendData(). Any idea what is missing?

AndyAndroid
  • 4,039
  • 14
  • 44
  • 71
  • Are you using any `Thread` for updating the Graph's values. By calling `appendData(...)` in a continued `postDelayed` fashion ? You are technically appending the same values on Click event, you are not updating the graph with different values on different points in time. – Salman Khakwani Dec 09 '14 at 11:53
  • correct for this example I would expect to see a horizontal line, but wanted to leave the coding simple for this post. Correct I only append the data to my array I don't tell the graph to update. But how do I tell the graph to update? That doesn't seem to be mentioned in the documentation. I don't have any thread / postDelayed or anything. Only main activity and onClickButton. Really simple to start. – AndyAndroid Dec 09 '14 at 13:08
  • normally the graph get's refreshed automatically. maybe you can not see the new data because it is out of the viewport. Try to set the parameter scrollToEnd=true. If it's still not working make a new issue at the project issue tracker at github – appsthatmatter Jan 21 '15 at 15:24

1 Answers1

0

replace this:exampleSeries.appendData(g, false, 50);

with this:exampleSeries.appendData(new DataPoint(x,y),true,22);

where : x and y are the new datapoints true means enable viewport keeps up with the new datapoints, i.e your screen will always show the most recently updated points 22 is the number of points you want to be kept .the rest will be lost to memory

sid.s
  • 315
  • 2
  • 10