我想使用JSON格式的loop或function动态添加数据集
var data3 = "{ datasets: [ ";
for (i = 0; i < data1.length; i++) {
data3 += "{ label: 'Time Violation',data: " + 5 + ",backgroundColor: 'rgba(244, 87, 126, 1)'},";
}
data3 += "],borderWidth: 1,labels: " + labels + "};";
我希望使用动态数据集以Charts.js数据格式生成结果
var StackedChart = new Chart(ctx1, {
type: 'bar',
data: data1,
options: options
});