How to update the graph chart.js?

Have a database of type Mysql . Using ajax I get the data from the php method into json and display on the basis of their schedule. At the moment, put filtration . How to update the graph based on the new(filtered) data. Using a library Chart.js.
June 5th 19 at 21:48
2 answers
June 5th 19 at 21:50
Solution
chart.update();

Doc
June 5th 19 at 21:52
Solution
Change the data in datasets and labels, then call the update () method:

chart.data.labels = newLabels
chart.data.datasets = newDatasets
chart.update()


documentation
Error: Uncaught TypeError: Cannot create property '_meta' on string '0.00'
Code:
$('form').submit(function ()
{
$.ajax({
 method: 'POST',
 url: 'dashboard/: filter',
 success: function (data) {
 var percent=[];
 var names=[];
 var colors=[];
 $.each(JSON.parse(data), function(index, report)
{
percent.push(report.count_percent)
});
 $.each(JSON.parse(data), function(index, name)
{
names.push(name.resname)
});
 $.each(names, function()
{
colors.push(getRandomColor())
});

 // console.log(data);

globalChart.data.labels=names;
globalChart.data.datasets=percent;
globalChart.update();
}
});
 return false;
 });
- Margaretta commented on June 5th 19 at 21:55
,
globalChart.data.datasets=[percent]; - thurman_Considine commented on June 5th 19 at 21:58
Error :Cannot set property 'font' of null - Margaretta commented on June 5th 19 at 22:01
somewhere in the logic error. From the same data somehow 2 different cycle. - thurman_Considine commented on June 5th 19 at 22:04

Find more questions by tags JavaScriptAJAX