读取 d3 键值



我有csv file的标头是 Station IDElevLatitudeLongitudeCountyNat_IDYear_BuiltCapacityYrsStr1YrsStr2 , .....在这里,我想获取从YrsStr1YrsSt578的所有列的值,并跳过其他列值。下面是跳过列的代码,但我无法获取列值?

 var hd = d3.keys(res[0]);
        for (var i = hd.length - 1; i >= 0; i--) {
            if( (hd[i] === "Station") || (hd[i] === "ID") || (hd[i] === "Elev") || (hd[i] === "Latitude")
                || (hd[i] === "Longitude") || (hd[i] === "County") || (hd[i] === "Nat_ID") || (hd[i] === "Year_Built")
                || (hd[i] === "Capacity")){
            }else{
            }
        }

使用
if(hd[i].include("YrsStr")){

供参考的代码笔网址http://codepen.io/nagasai/pen/pbyvmG

               for (var i = hd.length - 1; i >= 0; i--) {
                   if(hd[i].includes("YrsStr")){
                        console.log("key"+hd[i] +"--value"+res[hd[i]]);
                }

最新更新