我正在制作laravel项目,用户可以在其中查看图形信息。我在chart.js中遇到有关“传奇”的问题。当我在Ajax函数内部启动图例时,图例似乎未加载,但是在Ajax函数外部调用时,图例似乎已加载。您能帮我解决这个问题吗?...
下面是我用于项目的jquery代码。
var ageGroup = document.getElementById("myChartAgeGroup");
$.ajax({
type: 'GET',
url:'{{URL::to('benef/graph')}}',
success:function (data) {
//Benef Age Group Graph Codes
var myChartAgeGroup = new Chart(ageGroup, {
type: 'pie',
data: {
// These labels appear in the legend and in the tooltips when hovering different arcs
labels: ['Below 15','15-29','30-45','45 above'],
datasets: [{
label: "Age Group",
backgroundColor: ["#3e95cd","#8e5ea2","#3cba9f","#c45850"],
borderColor:'black',
borderWidth: 1,
data: [10, 20, 30, 40]
}],
},
options: {
title: {
display: true,
text: 'Age Group (%)'
},
}
});
//End Benef Age Group Graph Code
},
error:function () {
}
});