如何使用数据并在变量内部使用循环?我想在变量内部使用for循环将数据提供给变量,以便将数据提供给其内部的多维数组
我有这样的代码:
window.onload = function () {
var nape = ["per a", "per b"];
var dp = [{'x':3,'y':5}];
var chart = new CanvasJS.Chart("chartContainer", {
animationEnabled: true,
title:{
text: "Server Performance"
},
axisX: {
title:"Server Load (in TPS)"
},
axisY:{
labelFormatter: function(e){
if(e.value==0){
a="Provinsi"
return a;
}else if(e.value==1){
a="Aceh"
return a;
}else if(e.value==2){
a="Maluku"
return a;
}else if(e.value==3){
a="NTT"
return a;
}else if(e.value==4){
a="NTB"
return a;
}else if(e.value==5){
a="Jakarta"
return a;
}else if(e.value==6){
a="Sumatera"
return a;
}else if(e.value==7){
a="Kalimantan"
return a;
}
},
title: "Response Time (in ms)",
interval: 1,
},
data: [{
"type": "scatter",
toolTipContent: "<span>{name}</span><br/> Load: {x} TPS<br/> Response Time:</span> {y} ms",
name: nape[0],
showInLegend: true,
dataPoints: [
{ x: 23, y: 1 },
{ x: 28, y: 2 },
{ x: 39, y: 3 },
{ x: 34, y: 4 },
{ x: 24, y: 5 },
{ x: 29, y: 6 },
{ x: 29, y: 1 },
{ x: 23, y: 2 },
{ x: 27, y: 3 },
{ x: 34, y: 4 },
{ x: 36, y: 5 },
{ x: 33, y: 6 },
{ x: 32, y: 1 },
{ x: 21, y: 2 }
]
},
循环,我已经尝试了几种方法,但似乎很可惜,有人可以帮我吗?
BIG阳