I have a chart in which I am receiving several JSON and I would need to show that data in the chart, but when I try to show it, it does not do it and fails.
Example code:
{
"product": "Flour125",
"99": "2567",
"101": "123",
"102": "201"
}
The problem I am having is that I cannot display this data correctly, because when I try to display it, what it does is to take for example 99, 102, etc. and what I am trying to do is to show them by product.
Code:
setInterval(function() {
$.ajax({
url: 'product.php',
type: 'GET',
dataType: 'json',
success: function(data) {
for (var i = 0; i < data.length; i++) {
chartproduct.data.datasets[i].label = data[i]['product'];
chartproduct.data.datasets[i].data = data[i];
}
chartproduct.update();
}
});
}, 5000);
the graph I am trying to generate is of stacked type