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

2

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

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

Then I get the following error:

  

"TypeError: bar.save is not a function"

Has anyone successfully used this method yet?

    
asked by anonymous 11.12.2014 / 22:04

1 answer

2

According to documentation , the correct way to update a value in the bar chart is:

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

As you are doing, it is not the value of bar you are assigning, but bar integer . When update tries to save bar , it can not find method save (since integers do not have save ), hence the error you encountered:

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