我正在尝试为两种(或更多)产品(即驱蚊剂和液体肥皂)生成面积图。我正在使用 JavaScript 库 CanvasJS 来做到这一点。问题是我在这里需要大约 2000 个数据点而不是 4 个硬编码,问题是我无法为两个(或更多)产品生成一个 for 循环来为我执行此操作。谁能帮助我如何创建这个循环?
var chart = new CanvasJS.Chart("chartContainer", {
data: [{
type: "area",
name: "Mosquito Repellents",
showInLegend: "true",
dataPoints: [{
y: 83450,
label: "spring"
}, {
y: 51240,
label: "summer"
}, {
y: 64120,
label: "fall"
}, {
y: 71450,
label: "winter"
}
]
}, {
type: "area",
name: "Liquid Soap",
showInLegend: "true",
dataPoints: [{
y: 20140,
label: "spring"
}, {
y: 30170,
label: "summer"
}, {
y: 24410,
label: "autumn"
}, {
y: 38120,
label: "fall"
}
]
}]
});