0๐
You can not return from
ajax
as it isasynchronous
in nature, Usecallback
function or do the initialization ofbarChartData
in ajax success handler.
Try this:
$.ajax({
method: "GET",
cache: false,
url: "charts/applieschart.php",
success: function(myData) {
var chartjsLabel = [];
var chartjsData = [];
for (var i = 0; i < myData.length; i++) {
chartjsData.push(myData[i].count);
chartjsLabel.push(myData[i].date);
}
var barChartData = {
labels: chartjsLabel,
datasets: [{
fillColor: "rgba(220,280,220,0.5)",
strokeColor: "rgba(220,220,220,1)",
data: chartjsData
}]
};
}
});
- [Chartjs]-Vue.js this.$el.getContext('2d') is not a function
- [Chartjs]-Chart.js custom legend โ make legend items clickable to select/deselect data
Source:stackexchange.com