Search code examples
androidandroid-graphview

How to redraw correctly bargraphview using the graph view library for Android?


For some reason (that I can develop if you want/need) I have to redraw all the chart periodically. So, I use removeAllSeries then addSeries, plus removeAllViews then addView. It works but the problem is that addView adds the view not by simply refreshing all pixels of the tablet but with a sort of "animation" that puts firstly the View a little bit (2 or 3 pixels) shifted to the right and then it takes the right place. The consequence is that, everytime I redraw my graph, it looks as if there is a "vibration" (it's not fluid).

Do anyone have some issue? Could this undesired "animation" be related to how the addView method is done?


Solution

  • there are three ways:

    1. redrawAll() method. Maybe it is protected, but you can overwrite and make it public
    2. change the data in series (appendData or resetData). The Graph will automatically rerender.
    3. removeAllSeries + add new series. No need to call removeAllViews/addView. Take a look at the GraphViews-Demos project, there is an example about that.

    Cheers