Reputation: 2794
I have multiple data sets and want to change when a button is clicked. Here is an example of what I need: http://codepen.io/marcelo2605/pen/JEoGEO?editors=1010
If I click on 'set 2' button, the chart load the correct data.
But when I try to load 'set 1', nothing happens.
When I inspect using console.log
, I saw that foo
variable value is the same for both buttons.
Upvotes: 1
Views: 5000
Reputation: 1468
Change this :
myChart.data.datasets[0] = foo['datasets'][0];
myChart.data.labels = foo['labels'];
myChart.update();
To this :
myChart.config.data = foo;
myChart.update();
Edit after comments :
Upvotes: 2