I'm building a dashboard and I want to display information from my database directly to Chart.js.
I've created the Ajax and it returns the correct data. I've put this altogether in the following code:
$.ajax({
type: 'GET',
url: "http://localhost/cwwa/web/app.php/AJAX/dashboard/",
contentType: "application/json",
success: function(json) {
var ChartData = json.enviFig;
var oacData = [
$.each(ChartData, function(i, item) {
{
value: ChartData[i].totalTonne;
color: "#F7464A";
highlight: "#FF5A5E";
label: ChartData[i].wasteType;
}
})
];
var rCM = document.getElementById("recycledChartMain").getContext("2d");
var recycledChartMain = new Chart(rCM).Pie(oacData);
}
});
However, when the page is loaded the graph doesn't appear. Firebug doesn't an error either, only this warning relating to the Chart.js file:
canvas: an attempt to set strokeStyle or fillStyle to a value that is neither a string, a CanvasGradient, or a CanvasPattern was ignored.
What's going wrong?