Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I change PieChart when the data changes. #44

Open
TugrulhanCinar opened this issue Jul 27, 2020 · 4 comments
Open

How do I change PieChart when the data changes. #44

TugrulhanCinar opened this issue Jul 27, 2020 · 4 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@TugrulhanCinar
Copy link

TugrulhanCinar commented Jul 27, 2020

I’m changing the data but piechart still doesn’t change even i use the setState, how can i do it?

@arnauete52
Copy link

you manage to solve that?? :(

@TugrulhanCinar
Copy link
Author

no i couldn't :( no i started using fl_chart 0.11.0

@apgapg
Copy link
Owner

apgapg commented Sep 5, 2020

I already added this method

  @override
  void didUpdateWidget(PieChart oldWidget) {
    initData();
    super.didUpdateWidget(oldWidget);
  }

Looks like this doesn't work. Will check it

@apgapg apgapg self-assigned this Sep 5, 2020
@apgapg apgapg added the good first issue Good for newcomers label Sep 5, 2020
@apgapg
Copy link
Owner

apgapg commented Sep 5, 2020

For the time being one can add ValueKey to pie chart like this:
key: ValueKey(key),

and on changing data you can update the key like:

 RaisedButton(
            onPressed: () {
              setState(() {
                key = key + 1;
              });
            },
            child: Text("Reload".toUpperCase()),
          ),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants