Chart.js update method displays "bar.save is not a Function" error

Asked

Viewed 171 times

2

I’m using the Chart js. to plot graphics, but the problem occurs when I try to update it using the method update().

myBar.datasets[0].bars[0]=10;
myBar.update();

Then I get the following error:

"Typeerror: bar.save is not a Function"

Someone has already successfully used this method?

  • 1

    You can put your object myBar...

  • Probably the elements of bars are not integer, but objects with a method save. See on source code the functions update and eachBars (line 2080). Are you sure this is the right way to change a chart? It’s not ...bars[0].algumaOutraCoisa = 10?

1 answer

2

According to the documentation, the correct way to update a value on the bar graph is:

myBar.datasets[0].bars[0].value = 10;
myBar.update();

The way you’re doing it, it’s not the value of bar that you are assigning, and yes the bar whole. When the update tries to save the bar, he can’t find the method save (for whole have not save), hence the error you found:

update : function(){
    ...
    this.eachBars(function(bar){
        bar.save(); // Aqui ocorreu o erro
    });
    ...
},

Browser other questions tagged

You are not signed in. Login or sign up in order to post.