所以,我试图制作2个javascript方法。第一种方法是使用graphMaking和另一种方法将正确的参数发送到第一种方法,根据发送的参数制作图。问题是,我需要循环使用“arguments [i]”发送的参数按顺序形成一串:
data [i] .Names ==“A”|| data [i] .Names ==“B”
这就是我想出的:
var numIndex = [];
var cityString = "";
for (var j = 1; j < arguments.length; j++)
{
cityString = cityString + "||" + " data[i].Names==\"" + arguments[j] + "\"";
alert(arguments[j]);
}
cityString = "data[i].Names==\"" + arguments[0] + "\"";
for (var i = 0; i < data.length; i++) {
if (cityString)
{
numIndex.push(i);
}
}
我的if(cityString)应该在rder中被替换为什么? 在此先感谢:)
/////////////////////////////////////////////// ////////////////////////////////////////////////// ////////////////////////////////////////////
[编辑]好的,真正的交易为什么它的C#是因为我在asp.net中做代码,这对我来说是愚蠢的,并且是真正的代码:
function makeGraph() {
var chrt = document.getElementById("myCanvas");
$.ajax({
url: '../api/values',
type: 'GET',
datatype: 'json',
success: function (data) {
var totalLabel = [];
var totalValue = [];
var totalLabel2 = [];
var totalValue2 = [];
var cityValue = [];
var cityName = [];
var numIndex = [];
var cityString = "";
for (var j = 1; j < arguments.length; j++)
{
cityString = cityString + "||" + " data[i].Names==\"" + arguments[j] + "\"";
alert(arguments[j]);
}
cityString = "data[i].Names==\"" + arguments[0] + "\"";
for (var i = 0; i < data.length; i++) {
totalLabel.push(data[i].Names);
totalValue.push(data[i].ValuesDouble);
totalLabel2.push(data[i].Names2);
totalValue2.push(data[i].ValuesDouble2);
if (cityString) {
numIndex.push(i);
}
}
for (var k = 0; k < numIndex.length; k++) {
cityValue.push(data[numIndex[k]].ValuesDouble);
cityName.push(data[numIndex[k]].Names);
}
$(function () {
Highcharts.chart('container', {
chart: {
type: 'column',
backgroundColor: 'black'
},
title: {
text: ''
},
xAxis: {
categories: cityName,
},
yAxis: {
min: 0,
tickInterval: 100000,
title: {
text: ''
}
},
legend: {
verticalAlign: 'top',
reversed: false,
backgroundColor: 'lightgrey'
},
plotOptions: {
series: {
stacking: 'normal'
}
},
series: [
{
name: 'Joe',
data: cityValue,
color: 'green'
},
{
name: 'Joe',
data: cityValue,
color: 'yellow'
},
{
name: 'Jane',
data: cityValue,
color: 'blue'
}]
});
});
}
})
}
答案 0 :(得分:0)
我终于找到了自己的答案,即使用eval(“if-statement”),其中if-statement是字符串形式的if条件