我正在尝试仅使用“ zelcash”的结果构建图表。当前它仅显示为Zelcash,但是我的结果显示zelcash的哈希率以及实际的哈希率均为0,导致折线图上下波动。如果我可以过滤掉所有其他内容(snowgem,votecoin,Commercium),那么它应该正确显示。

function buildChartData(){
    var pools = {};

    poolKeys = [];
    for (var i = 0; i < statData.length; i++){
        for (var pool in statData[i].pools){
            if (poolKeys.indexOf("zelcash") === -1)
                poolKeys.push("zelcash");
        }
    }

    for (var i = 0; i < statData.length; i++) {
        var time = statData[i].time * 1000;
        for (var f = 0; f < poolKeys.length; f++){
            var pName = poolKeys[f];
            var a = pools[pName] = (pools[pName] || {
                hashrate: []
            });
            if (pName in statData[i].pools){
                a.hashrate.push([time, statData[i].pools[pName].hashrate]);
            }
            else{
                a.hashrate.push([time, 0]);
            }
        }
    }

    poolHashrateData = [];
    for (var pool in pools){
       poolHashrateData.push({
            key: pool,
            values: pools[pool].hashrate
        });
        $('#statsHashrateAvg' + pool).text(getReadableHashRateString(calculateAverageHashrate(pool)));
    }
}

function displayCharts(){
    nv.addGraph(function() {
        poolHashrateChart = nv.models.lineChart()
            .margin({left: 80, right: 30})
            .x(function(d){ return d[0] })
            .y(function(d){ return d[1] })
            .useInteractiveGuideline(true);

        poolHashrateChart.xAxis.tickFormat(timeOfDayFormat);

        poolHashrateChart.yAxis.tickFormat(function(d){
            return getReadableHashRateString(d);
        });

        d3.select('#poolHashrate').datum(poolHashrateData).call(poolHashrateChart);

        return poolHashrateChart;
    });
}

$.getJSON('/api/pool_stats', function(data){
    statData = data;
    buildChartData();
    displayCharts();
});


JSON:

[
{
"time": 1529585412,
"pools": {
"commercium": {
"hashrate": 5189503226.486427,
"workerCount": 4,
"blocks": {
"pending": 0,
"confirmed": 16,
"orphaned": 0
}
}
}
},
{
"time": 1529585412,
"pools": {
"snowgem": {
"hashrate": 62455228153.806404,
"workerCount": 24,
"blocks": {
"pending": 3,
"confirmed": 4331,
"orphaned": 91
}
}
}
},
{
"time": 1529585417,
"pools": {
"votecoin": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 8,
"orphaned": 1
}
}
}
},
{
"time": 1529585427,
"pools": {
"zelcash": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 54,
"orphaned": 0
}
}
}
},
{
"time": 1529585442,
"pools": {
"commercium": {
"hashrate": 4826505080.966065,
"workerCount": 4,
"blocks": {
"pending": 0,
"confirmed": 16,
"orphaned": 0
}
}
}
},
{
"time": 1529585442,
"pools": {
"snowgem": {
"hashrate": 60264584320.178246,
"workerCount": 24,
"blocks": {
"pending": 3,
"confirmed": 4331,
"orphaned": 91
}
}
}
},
{
"time": 1529585447,
"pools": {
"votecoin": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 8,
"orphaned": 1
}
}
}
},
{
"time": 1529585457,
"pools": {
"zelcash": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 54,
"orphaned": 0
}
}
}
},
{
"time": 1529585472,
"pools": {
"snowgem": {
"hashrate": 60276471845.76297,
"workerCount": 24,
"blocks": {
"pending": 3,
"confirmed": 4331,
"orphaned": 91
}
}
}
},
{
"time": 1529585472,
"pools": {
"commercium": {
"hashrate": 5226784726.022363,
"workerCount": 4,
"blocks": {
"pending": 0,
"confirmed": 16,
"orphaned": 0
}
}
}
},
{
"time": 1529585477,
"pools": {
"votecoin": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 8,
"orphaned": 1
}
}
}
},
{
"time": 1529585487,
"pools": {
"zelcash": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 54,
"orphaned": 0
}
}
}
},
{
"time": 1529585502,
"pools": {
"snowgem": {
"hashrate": 60082774365.37301,
"workerCount": 24,
"blocks": {
"pending": 3,
"confirmed": 4331,
"orphaned": 91
}
}
}
},
{
"time": 1529585502,
"pools": {
"commercium": {
"hashrate": 5134407544.497634,
"workerCount": 4,
"blocks": {
"pending": 0,
"confirmed": 16,
"orphaned": 0
}
}
}
},
{
"time": 1529585507,
"pools": {
"votecoin": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 8,
"orphaned": 1
}
}
}
},
{
"time": 1529585517,
"pools": {
"zelcash": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 54,
"orphaned": 0
}
}
}
},
{
"time": 1529585532,
"pools": {
"commercium": {
"hashrate": 5124529174.406084,
"workerCount": 4,
"blocks": {
"pending": 0,
"confirmed": 16,
"orphaned": 0
}
}
}
},
{
"time": 1529585532,
"pools": {
"snowgem": {
"hashrate": 59031518431.05017,
"workerCount": 24,
"blocks": {
"pending": 3,
"confirmed": 4331,
"orphaned": 91
}
}
}
},
{
"time": 1529585537,
"pools": {
"votecoin": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 8,
"orphaned": 1
}
}
}
},
{
"time": 1529585547,
"pools": {
"zelcash": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 54,
"orphaned": 0
}
}
}
},
{
"time": 1529585562,
"pools": {
"commercium": {
"hashrate": 5167587777.47197,
"workerCount": 4,
"blocks": {
"pending": 0,
"confirmed": 16,
"orphaned": 0
}
}
}
},
{
"time": 1529585562,
"pools": {
"snowgem": {
"hashrate": 59467855860.86194,
"workerCount": 24,
"blocks": {
"pending": 3,
"confirmed": 4331,
"orphaned": 91
}
}
}
},
{
"time": 1529585567,
"pools": {
"votecoin": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 8,
"orphaned": 1
}
}
}
},
{
"time": 1529585577,
"pools": {
"zelcash": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 54,
"orphaned": 0
}
}
}
},
{
"time": 1529585592,
"pools": {
"commercium": {
"hashrate": 5015590053.670292,
"workerCount": 4,
"blocks": {
"pending": 0,
"confirmed": 16,
"orphaned": 0
}
}
}
},
{
"time": 1529585592,
"pools": {
"snowgem": {
"hashrate": 58548787432.08826,
"workerCount": 24,
"blocks": {
"pending": 3,
"confirmed": 4331,
"orphaned": 91
}
}
}
},
{
"time": 1529585597,
"pools": {
"votecoin": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 8,
"orphaned": 1
}
}
}
},
{
"time": 1529585607,
"pools": {
"zelcash": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 54,
"orphaned": 0
}
}
}
},
{
"time": 1529585622,
"pools": {
"snowgem": {
"hashrate": 57356460429.32182,
"workerCount": 24,
"blocks": {
"pending": 3,
"confirmed": 4331,
"orphaned": 91
}
}
}
},
{
"time": 1529585622,
"pools": {
"commercium": {
"hashrate": 4547179358.5752535,
"workerCount": 4,
"blocks": {
"pending": 0,
"confirmed": 16,
"orphaned": 0
}
}
}
},
{
"time": 1529585627,
"pools": {
"votecoin": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 8,
"orphaned": 1
}
}
}
},
{
"time": 1529585637,
"pools": {
"zelcash": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 54,
"orphaned": 0
}
}
}
},
{
"time": 1529585652,
"pools": {
"commercium": {
"hashrate": 4171779429.704191,
"workerCount": 4,
"blocks": {
"pending": 0,
"confirmed": 16,
"orphaned": 0
}
}
}
},
{
"time": 1529585652,
"pools": {
"snowgem": {
"hashrate": 57682632330.67274,
"workerCount": 24,
"blocks": {
"pending": 3,
"confirmed": 4331,
"orphaned": 91
}
}
}
},
{
"time": 1529585657,
"pools": {
"votecoin": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 8,
"orphaned": 1
}
}
}
},
{
"time": 1529585667,
"pools": {
"zelcash": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 54,
"orphaned": 0
}
}
}
},
{
"time": 1529585682,
"pools": {
"commercium": {
"hashrate": 3801445874.6065907,
"workerCount": 4,
"blocks": {
"pending": 0,
"confirmed": 16,
"orphaned": 0
}
}
}
},
{
"time": 1529585682,
"pools": {
"snowgem": {
"hashrate": 57873303213.8949,
"workerCount": 24,
"blocks": {
"pending": 3,
"confirmed": 4331,
"orphaned": 91
}
}
}
},
{
"time": 1529585687,
"pools": {
"votecoin": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 8,
"orphaned": 1
}
}
}
},
{
"time": 1529585697,
"pools": {
"zelcash": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 54,
"orphaned": 0
}
}
}
},
{
"time": 1529585712,
"pools": {
"snowgem": {
"hashrate": 56758457066.24074,
"workerCount": 24,
"blocks": {
"pending": 3,
"confirmed": 4331,
"orphaned": 91
}
}
}
},
{
"time": 1529585712,
"pools": {
"commercium": {
"hashrate": 3580809391.107298,
"workerCount": 4,
"blocks": {
"pending": 0,
"confirmed": 16,
"orphaned": 0
}
}
}
},
{
"time": 1529585717,
"pools": {
"votecoin": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 8,
"orphaned": 1
}
}
}
},
{
"time": 1529585727,
"pools": {
"zelcash": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 54,
"orphaned": 0
}
}
}
},
{
"time": 1529585742,
"pools": {
"snowgem": {
"hashrate": 57417619072.68825,
"workerCount": 24,
"blocks": {
"pending": 3,
"confirmed": 4331,
"orphaned": 91
}
}
}
},
{
"time": 1529585742,
"pools": {
"commercium": {
"hashrate": 3735600891.2054467,
"workerCount": 4,
"blocks": {
"pending": 0,
"confirmed": 16,
"orphaned": 0
}
}
}
},
{
"time": 1529585747,
"pools": {
"votecoin": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 8,
"orphaned": 1
}
}
}
},
{
"time": 1529585757,
"pools": {
"zelcash": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 54,
"orphaned": 0
}
}
}
},
{
"time": 1529585772,
"pools": {
"snowgem": {
"hashrate": 58773508427.48176,
"workerCount": 24,
"blocks": {
"pending": 3,
"confirmed": 4331,
"orphaned": 91
}
}
}
},
{
"time": 1529585772,
"pools": {
"commercium": {
"hashrate": 3795961049.6140885,
"workerCount": 4,
"blocks": {
"pending": 0,
"confirmed": 16,
"orphaned": 0
}
}
}
},
{
"time": 1529585777,
"pools": {
"votecoin": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 8,
"orphaned": 1
}
}
}
},
{
"time": 1529585787,
"pools": {
"zelcash": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 54,
"orphaned": 0
}
}
}
},
{
"time": 1529585802,
"pools": {
"commercium": {
"hashrate": 3967268723.040279,
"workerCount": 4,
"blocks": {
"pending": 0,
"confirmed": 16,
"orphaned": 0
}
}
}
},
{
"time": 1529585802,
"pools": {
"snowgem": {
"hashrate": 59362826828.24458,
"workerCount": 24,
"blocks": {
"pending": 3,
"confirmed": 4331,
"orphaned": 91
}
}
}
},
{
"time": 1529585807,
"pools": {
"votecoin": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 8,
"orphaned": 1
}
}
}
},
{
"time": 1529585817,
"pools": {
"zelcash": {
"hashrate": 3579139.4133333336,
"workerCount": 1,
"blocks": {
"pending": 0,
"confirmed": 54,
"orphaned": 0
}
}
}
},
{
"time": 1529585832,
"pools": {
"snowgem": {
"hashrate": 58784159990.75724,
"workerCount": 24,
"blocks": {
"pending": 3,
"confirmed": 4331,
"orphaned": 91
}
}
}
},
{
"time": 1529585832,
"pools": {
"commercium": {
"hashrate": 4022981550.4546576,
"workerCount": 4,
"blocks": {
"pending": 0,
"confirmed": 16,
"orphaned": 0
}
}
}
},
{
"time": 1529585837,
"pools": {
"votecoin": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 8,
"orphaned": 1
}
}
}
},
{
"time": 1529585847,
"pools": {
"zelcash": {
"hashrate": 32928082.602666665,
"workerCount": 1,
"blocks": {
"pending": 0,
"confirmed": 54,
"orphaned": 0
}
}
}
},
{
"time": 1529585862,
"pools": {
"commercium": {
"hashrate": 3856961602.6789494,
"workerCount": 4,
"blocks": {
"pending": 0,
"confirmed": 16,
"orphaned": 0
}
}
}
},
{
"time": 1529585862,
"pools": {
"snowgem": {
"hashrate": 58188175912.56337,
"workerCount": 24,
"blocks": {
"pending": 3,
"confirmed": 4331,
"orphaned": 91
}
}
}
},
{
"time": 1529585867,
"pools": {
"votecoin": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 8,
"orphaned": 1
}
}
}
},
{
"time": 1529585877,
"pools": {
"zelcash": {
"hashrate": 65856165.205333255,
"workerCount": 1,
"blocks": {
"pending": 0,
"confirmed": 54,
"orphaned": 0
}
}
}
},
{
"time": 1529585892,
"pools": {
"commercium": {
"hashrate": 4147019547.5446525,
"workerCount": 4,
"blocks": {
"pending": 0,
"confirmed": 16,
"orphaned": 0
}
}
}
},
{
"time": 1529585892,
"pools": {
"snowgem": {
"hashrate": 58982350607.23202,
"workerCount": 24,
"blocks": {
"pending": 3,
"confirmed": 4331,
"orphaned": 91
}
}
}
},
{
"time": 1529585897,
"pools": {
"votecoin": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 8,
"orphaned": 1
}
}
}
},
{
"time": 1529585907,
"pools": {
"zelcash": {
"hashrate": 77309411.32799992,
"workerCount": 1,
"blocks": {
"pending": 0,
"confirmed": 54,
"orphaned": 0
}
}
}
},
{
"time": 1529585922,
"pools": {
"snowgem": {
"hashrate": 59707725151.648636,
"workerCount": 24,
"blocks": {
"pending": 3,
"confirmed": 4331,
"orphaned": 91
}
}
}
},
{
"time": 1529585922,
"pools": {
"commercium": {
"hashrate": 4110286531.796457,
"workerCount": 4,
"blocks": {
"pending": 0,
"confirmed": 16,
"orphaned": 0
}
}
}
},
{
"time": 1529585927,
"pools": {
"votecoin": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 8,
"orphaned": 1
}
}
}
},
{
"time": 1529585937,
"pools": {
"zelcash": {
"hashrate": 88762657.45066658,
"workerCount": 1,
"blocks": {
"pending": 0,
"confirmed": 54,
"orphaned": 0
}
}
}
},
{
"time": 1529585952,
"pools": {
"commercium": {
"hashrate": 4106604483.6782217,
"workerCount": 4,
"blocks": {
"pending": 0,
"confirmed": 16,
"orphaned": 0
}
}
}
},
{
"time": 1529585952,
"pools": {
"snowgem": {
"hashrate": 57752153491.97392,
"workerCount": 24,
"blocks": {
"pending": 3,
"confirmed": 4331,
"orphaned": 91
}
}
}
},
{
"time": 1529585957,
"pools": {
"votecoin": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 8,
"orphaned": 1
}
}
}
},
{
"time": 1529585967,
"pools": {
"zelcash": {
"hashrate": 88762657.45066658,
"workerCount": 1,
"blocks": {
"pending": 0,
"confirmed": 54,
"orphaned": 0
}
}
}
},
{
"time": 1529585982,
"pools": {
"snowgem": {
"hashrate": 58370591917.46198,
"workerCount": 24,
"blocks": {
"pending": 3,
"confirmed": 4331,
"orphaned": 91
}
}
}
},
{
"time": 1529585982,
"pools": {
"commercium": {
"hashrate": 3951235054.641875,
"workerCount": 4,
"blocks": {
"pending": 0,
"confirmed": 16,
"orphaned": 0
}
}
}
},
{
"time": 1529585987,
"pools": {
"votecoin": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 8,
"orphaned": 1
}
}
}
},
{
"time": 1529585997,
"pools": {
"zelcash": {
"hashrate": 88762657.45066658,
"workerCount": 1,
"blocks": {
"pending": 0,
"confirmed": 54,
"orphaned": 0
}
}
}
},
{
"time": 1529586012,
"pools": {
"snowgem": {
"hashrate": 56854008763.89342,
"workerCount": 24,
"blocks": {
"pending": 3,
"confirmed": 4331,
"orphaned": 91
}
}
}
},
{
"time": 1529586012,
"pools": {
"commercium": {
"hashrate": 3793349396.108675,
"workerCount": 4,
"blocks": {
"pending": 0,
"confirmed": 16,
"orphaned": 0
}
}
}
},
{
"time": 1529586017,
"pools": {
"votecoin": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 8,
"orphaned": 1
}
}
}
},
{
"time": 1529586027,
"pools": {
"zelcash": {
"hashrate": 88762657.45066658,
"workerCount": 1,
"blocks": {
"pending": 0,
"confirmed": 54,
"orphaned": 0
}
}
}
},
{
"time": 1529586042,
"pools": {
"snowgem": {
"hashrate": 55640179547.09381,
"workerCount": 24,
"blocks": {
"pending": 3,
"confirmed": 4331,
"orphaned": 91
}
}
}
},
{
"time": 1529586042,
"pools": {
"commercium": {
"hashrate": 4254907905.963128,
"workerCount": 4,
"blocks": {
"pending": 0,
"confirmed": 16,
"orphaned": 0
}
}
}
},
{
"time": 1529586047,
"pools": {
"votecoin": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 8,
"orphaned": 1
}
}
}
},
{
"time": 1529586057,
"pools": {
"zelcash": {
"hashrate": 88762657.45066658,
"workerCount": 1,
"blocks": {
"pending": 0,
"confirmed": 54,
"orphaned": 0
}
}
}
},
{
"time": 1529586072,
"pools": {
"snowgem": {
"hashrate": 54815827606.03803,
"workerCount": 24,
"blocks": {
"pending": 3,
"confirmed": 4331,
"orphaned": 91
}
}
}
},
{
"time": 1529586072,
"pools": {
"commercium": {
"hashrate": 4068543917.5906467,
"workerCount": 3,
"blocks": {
"pending": 0,
"confirmed": 16,
"orphaned": 0
}
}
}
},
{
"time": 1529586077,
"pools": {
"votecoin": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 8,
"orphaned": 1
}
}
}
},
{
"time": 1529586087,
"pools": {
"zelcash": {
"hashrate": 136155400.0617755,
"workerCount": 1,
"blocks": {
"pending": 0,
"confirmed": 54,
"orphaned": 0
}
}
}
},
{
"time": 1529586102,
"pools": {
"snowgem": {
"hashrate": 54247558805.34688,
"workerCount": 24,
"blocks": {
"pending": 3,
"confirmed": 4331,
"orphaned": 91
}
}
}
},
{
"time": 1529586102,
"pools": {
"commercium": {
"hashrate": 3663845737.3112593,
"workerCount": 3,
"blocks": {
"pending": 0,
"confirmed": 16,
"orphaned": 0
}
}
}
},
{
"time": 1529586107,
"pools": {
"votecoin": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 8,
"orphaned": 1
}
}
}
},
{
"time": 1529586117,
"pools": {
"zelcash": {
"hashrate": 147140617.01258057,
"workerCount": 1,
"blocks": {
"pending": 0,
"confirmed": 54,
"orphaned": 0
}
}
}
},
{
"time": 1529586132,
"pools": {
"commercium": {
"hashrate": 3872995539.083314,
"workerCount": 3,
"blocks": {
"pending": 0,
"confirmed": 16,
"orphaned": 0
}
}
}
},
{
"time": 1529586132,
"pools": {
"snowgem": {
"hashrate": 57481995362.95994,
"workerCount": 24,
"blocks": {
"pending": 3,
"confirmed": 4331,
"orphaned": 91
}
}
}
},
{
"time": 1529586137,
"pools": {
"votecoin": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 8,
"orphaned": 1
}
}
}
},
{
"time": 1529586147,
"pools": {
"zelcash": {
"hashrate": 132356030.1873857,
"workerCount": 1,
"blocks": {
"pending": 0,
"confirmed": 54,
"orphaned": 0
}
}
}
},
{
"time": 1529586162,
"pools": {
"snowgem": {
"hashrate": 57266391210.46424,
"workerCount": 24,
"blocks": {
"pending": 3,
"confirmed": 4331,
"orphaned": 91
}
}
}
},
{
"time": 1529586162,
"pools": {
"commercium": {
"hashrate": 4464465073.357301,
"workerCount": 3,
"blocks": {
"pending": 0,
"confirmed": 16,
"orphaned": 0
}
}
}
},
{
"time": 1529586167,
"pools": {
"votecoin": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 8,
"orphaned": 1
}
}
}
},
{
"time": 1529586177,
"pools": {
"zelcash": {
"hashrate": 121077172.62183852,
"workerCount": 1,
"blocks": {
"pending": 0,
"confirmed": 54,
"orphaned": 0
}
}
}
},
{
"time": 1529586192,
"pools": {
"commercium": {
"hashrate": 4256786106.7580795,
"workerCount": 3,
"blocks": {
"pending": 0,
"confirmed": 16,
"orphaned": 0
}
}
}
},
{
"time": 1529586193,
"pools": {
"snowgem": {
"hashrate": 55936310547.9417,
"workerCount": 24,
"blocks": {
"pending": 3,
"confirmed": 4331,
"orphaned": 91
}
}
}
},
{
"time": 1529586197,
"pools": {
"votecoin": {
"hashrate": 0,
"workerCount": 0,
"blocks": {
"pending": 0,
"confirmed": 8,
"orphaned": 1
}
}
}
}
]

最佳答案

@John,您可以尝试下面的代码。


  使用data = data.filter((obj) => obj["pools"]['zelcash'] !== undefined)更新数据数组。


console.log('New length: ', data.length, '\n');

// Filter objects
data = data.filter((obj) => obj["pools"]['zelcash'] !== undefined)

// Pretty printing new array
console.log(JSON.stringify(data, undefined, 4));

console.log('\nNew length: ', data.length);


»输出

New length:  107

[
    {
        "time": 1529585427,
        "pools": {
            "zelcash": {
                "hashrate": 0,
                "workerCount": 0,
                "blocks": {
                    "pending": 0,
                    "confirmed": 54,
                    "orphaned": 0
                }
            }
        }
    },
    {
        "time": 1529585457,
        "pools": {
            "zelcash": {
                "hashrate": 0,
                "workerCount": 0,
                "blocks": {
                    "pending": 0,
                    "confirmed": 54,
                    "orphaned": 0
                }
            }
        }
    },
    {
        "time": 1529585487,
        "pools": {
            "zelcash": {
                "hashrate": 0,
                "workerCount": 0,
                "blocks": {
                    "pending": 0,
                    "confirmed": 54,
                    "orphaned": 0
                }
            }
        }
    },
    {
        "time": 1529585517,
        "pools": {
            "zelcash": {
                "hashrate": 0,
                "workerCount": 0,
                "blocks": {
                    "pending": 0,
                    "confirmed": 54,
                    "orphaned": 0
                }
            }
        }
    },
    {
        "time": 1529585547,
        "pools": {
            "zelcash": {
                "hashrate": 0,
                "workerCount": 0,
                "blocks": {
                    "pending": 0,
                    "confirmed": 54,
                    "orphaned": 0
                }
            }
        }
    },
    {
        "time": 1529585577,
        "pools": {
            "zelcash": {
                "hashrate": 0,
                "workerCount": 0,
                "blocks": {
                    "pending": 0,
                    "confirmed": 54,
                    "orphaned": 0
                }
            }
        }
    },
    {
        "time": 1529585607,
        "pools": {
            "zelcash": {
                "hashrate": 0,
                "workerCount": 0,
                "blocks": {
                    "pending": 0,
                    "confirmed": 54,
                    "orphaned": 0
                }
            }
        }
    },
    {
        "time": 1529585637,
        "pools": {
            "zelcash": {
                "hashrate": 0,
                "workerCount": 0,
                "blocks": {
                    "pending": 0,
                    "confirmed": 54,
                    "orphaned": 0
                }
            }
        }
    },
    {
        "time": 1529585667,
        "pools": {
            "zelcash": {
                "hashrate": 0,
                "workerCount": 0,
                "blocks": {
                    "pending": 0,
                    "confirmed": 54,
                    "orphaned": 0
                }
            }
        }
    },
    {
        "time": 1529585697,
        "pools": {
            "zelcash": {
                "hashrate": 0,
                "workerCount": 0,
                "blocks": {
                    "pending": 0,
                    "confirmed": 54,
                    "orphaned": 0
                }
            }
        }
    },
    {
        "time": 1529585727,
        "pools": {
            "zelcash": {
                "hashrate": 0,
                "workerCount": 0,
                "blocks": {
                    "pending": 0,
                    "confirmed": 54,
                    "orphaned": 0
                }
            }
        }
    },
    {
        "time": 1529585757,
        "pools": {
            "zelcash": {
                "hashrate": 0,
                "workerCount": 0,
                "blocks": {
                    "pending": 0,
                    "confirmed": 54,
                    "orphaned": 0
                }
            }
        }
    },
    {
        "time": 1529585787,
        "pools": {
            "zelcash": {
                "hashrate": 0,
                "workerCount": 0,
                "blocks": {
                    "pending": 0,
                    "confirmed": 54,
                    "orphaned": 0
                }
            }
        }
    },
    {
        "time": 1529585817,
        "pools": {
            "zelcash": {
                "hashrate": 3579139.4133333336,
                "workerCount": 1,
                "blocks": {
                    "pending": 0,
                    "confirmed": 54,
                    "orphaned": 0
                }
            }
        }
    },
    {
        "time": 1529585847,
        "pools": {
            "zelcash": {
                "hashrate": 32928082.602666665,
                "workerCount": 1,
                "blocks": {
                    "pending": 0,
                    "confirmed": 54,
                    "orphaned": 0
                }
            }
        }
    },
    {
        "time": 1529585877,
        "pools": {
            "zelcash": {
                "hashrate": 65856165.205333255,
                "workerCount": 1,
                "blocks": {
                    "pending": 0,
                    "confirmed": 54,
                    "orphaned": 0
                }
            }
        }
    },
    {
        "time": 1529585907,
        "pools": {
            "zelcash": {
                "hashrate": 77309411.32799992,
                "workerCount": 1,
                "blocks": {
                    "pending": 0,
                    "confirmed": 54,
                    "orphaned": 0
                }
            }
        }
    },
    {
        "time": 1529585937,
        "pools": {
            "zelcash": {
                "hashrate": 88762657.45066658,
                "workerCount": 1,
                "blocks": {
                    "pending": 0,
                    "confirmed": 54,
                    "orphaned": 0
                }
            }
        }
    },
    {
        "time": 1529585967,
        "pools": {
            "zelcash": {
                "hashrate": 88762657.45066658,
                "workerCount": 1,
                "blocks": {
                    "pending": 0,
                    "confirmed": 54,
                    "orphaned": 0
                }
            }
        }
    },
    {
        "time": 1529585997,
        "pools": {
            "zelcash": {
                "hashrate": 88762657.45066658,
                "workerCount": 1,
                "blocks": {
                    "pending": 0,
                    "confirmed": 54,
                    "orphaned": 0
                }
            }
        }
    },
    {
        "time": 1529586027,
        "pools": {
            "zelcash": {
                "hashrate": 88762657.45066658,
                "workerCount": 1,
                "blocks": {
                    "pending": 0,
                    "confirmed": 54,
                    "orphaned": 0
                }
            }
        }
    },
    {
        "time": 1529586057,
        "pools": {
            "zelcash": {
                "hashrate": 88762657.45066658,
                "workerCount": 1,
                "blocks": {
                    "pending": 0,
                    "confirmed": 54,
                    "orphaned": 0
                }
            }
        }
    },
    {
        "time": 1529586087,
        "pools": {
            "zelcash": {
                "hashrate": 136155400.0617755,
                "workerCount": 1,
                "blocks": {
                    "pending": 0,
                    "confirmed": 54,
                    "orphaned": 0
                }
            }
        }
    },
    {
        "time": 1529586117,
        "pools": {
            "zelcash": {
                "hashrate": 147140617.01258057,
                "workerCount": 1,
                "blocks": {
                    "pending": 0,
                    "confirmed": 54,
                    "orphaned": 0
                }
            }
        }
    },
    {
        "time": 1529586147,
        "pools": {
            "zelcash": {
                "hashrate": 132356030.1873857,
                "workerCount": 1,
                "blocks": {
                    "pending": 0,
                    "confirmed": 54,
                    "orphaned": 0
                }
            }
        }
    },
    {
        "time": 1529586177,
        "pools": {
            "zelcash": {
                "hashrate": 121077172.62183852,
                "workerCount": 1,
                "blocks": {
                    "pending": 0,
                    "confirmed": 54,
                    "orphaned": 0
                }
            }
        }
    }
]

New length:  26

07-27 18:33