正如标题所示,这是我的代码片段
angular.forEach($scope.students,function(){
var ctx = document.getElementById("myChart").getContext("2d");
var myRadarChart = new Chart(ctx).Radar(chartData);
//Data//
var subjects = [];
var scores = [];
angular.forEach(myData.subjects, function(subject){
subjects.push(myData.subject.name);
});
angular.forEach($scope.data.subjects, function(score){
scores.push(score.grades.assignments+score.grades.tests+score.grades.final);
});
var chartData = {
labels : subjects,
datasets : [
{
data: scores,
fillColor: color2,
strokeColor: color1,
pointColor: color1,
pointStrokeColor: color1,
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(220,220,220,1)"
}
]
};
});
}]);
我还有其他所有工作但我不确定如何为data.json中的每个对象唯一地正确初始化每个图表,有一个look