MPAndroidChart icon indicating copy to clipboard operation
MPAndroidChart copied to clipboard

Chart data(Barchart) in FRAGMENT (support v4) not updated even after calling notifyDataSetChanged

Open joe380 opened this issue 10 years ago • 3 comments

Well I created a with android studio from scratch: (is attached)

  • new project with NavigationView (side bar) (with wizard)
  • copied BarChartFrag + MyMarkerView + all layouts need for this fragment from library example to this project
  • created 2 method updateA and updateB in this fragment which basically simulate a postponed click/http call to get json response from server (you get the idea)

(use always either updateA or updateB to test different behaviour not both together) Problem:

  1. if I do not fill the chart with data before displaying fragment, after update event data will not be updated.
  2. if I fill data at start and the try to update it later, it will not be update until a click event on the chart happens (updateA() method)
  3. if I change data periodically (inspired by the example Realtime chart) the chart is not updated (updateB() method) chartbug.zip

Probalby this should be a another bug (but it could be associated with the invalidate problem) I attached a video, the probelm is during scaling the chart disappers. This is a similar structure also within fragment Google Nexus 4 - 5.1.0 - API 22 - 768x1280.zip

It's kind a blocker. Thx

joe380 avatar Feb 11 '16 15:02 joe380

You forgot to call chart.invalidate() in your update method.

PhilJay avatar Feb 11 '16 15:02 PhilJay

Thanks for the quick response, I tried to update the code with invalidate in the app with the scaling problem and it did not solve it. Should I create a new bug?

joe380 avatar Feb 11 '16 15:02 joe380

I suggest you read this: https://github.com/PhilJay/MPAndroidChart/wiki/Dynamic-&-Realtime-Data

PhilJay avatar Feb 11 '16 15:02 PhilJay