问题——判断stationData里的值大小并返回
如果stationData里的值在0.0-0.2区间内或者0.3-1.5区间(PS:有多个区间)则返回相对应的数组(一个区间一个数组)
stationData=[4.4, 4.4, 12.4, 3.4, 20.4, 4.4, 4.4, 3.4, 4.4, 12.4, 14.4, 4.4, 5.4, 7.4, 2.4, 4.4, 5.4, 12.4, 11.4, 3.4, 4.4, 6.4, 8.4, 3.4, 13.4]
for (let i = 0; i < val.length; i++) {
//stationData 赋值
that.cdata.Wind_Direction_2.push(val[i].Wind_Direction_2);
that.cdata.Wind_Direction_2 = that.cdata.Wind_Direction_2.map(Number);
var stationData = that.cdata.Wind_Speed_2.push(val[i].Wind_Speed_2);
stationData = that.cdata.Wind_Speed_2.map(Number); //数组,元素不带双引号,显示
//条件判断
for (var a = 0; a < stationData.length; a++) {
if (stationData[a] >= 0.0 && stationData[a] <= 0.2) {//判断条件
var legendData =stationData.push(stationData[a])
console.log(legendData)//未显示
}
}
}
let stationData = [4.4, 4.4, 12.4, 3.4, 20.4, 4.4, 4.4, 3.4, 4.4, 12.4, 14.4, 4.4, 5.4, 7.4, 2.4, 4.4, 5.4, 12.4, 11.4, 3.4, 4.4, 6.4, 8.4, 3.4, 13.4];
let rangeConfig = [{max: 4, min: 0}, {max: 7, min: 4}];
let res = rangeConfig.map(item => stationData.filter(num => num >= item.min && num <= item.max));
var legendData =stationData.push(stationData[a])
console.log(legendData)//未显示
//改成
var legendData=[]
legendData.push(stationData[a])
console.log(legendData)
let stationData = [4.4, 4.4, 12.4, 3.4, 20.4, 4.4, 4.4, 3.4, 4.4, 12.4, 14.4, 4.4, 5.4, 7.4, 2.4, 4.4, 5.4, 12.4, 11.4, 3.4, 4.4, 6.4, 8.4, 3.4, 13.4];
let arryOne=[]
let arryTwo=[]
stationData.map(item=>{
console.log(item)
if (item >= 0.0 && item <= 0.2){//条件判断
arryOne.push(item)
}else if (item >= 0.3 && item <= 1.5){//条件判断
arryTwo.push(item)
}
})
console.log(arryOne)
console.log(arryTwo)