nvd3 烛台图表不显示自定义数据

nvd3 candlestick chart not displaying custom data

我有一个 nvd3 angular 烛台图表,可以很好地显示硬编码数据。但是当我将它指向另一个数据源(socket.io)时,它不再显示了。

我从此处的套接字获取数据

 $scope.getdata = function () {
    console.log("getting data!");
    io.socket.get('/feed/getpolodata', function (data, jwr, err) {
        var values = [];
        angular.forEach(data.candleInfo, function (r) {
            //$scope.data
            values.push({

                "date": r.date,
                "close": r.close,
                "open": r.open,
                "high": r.high,
                "low": r.low,
                "volume": r.volume,
                "adjusted": r.low

            });

            if (err) {
                console.log("Error getting data")
            }
        });

        $scope.data.push({values});

        console.log("js" + JSON.stringify($scope.data));
        console.log("js2" + JSON.stringify($scope.data2));
    })
};

$scope.data 包含自定义数据,$scope.data 包含用于测试的硬编码数据。

数据2:

    $scope.data2 = [{
    values: [
        { "date": 1499031328, "close": 0.00008231, "open": 0.0000816, "high": 0.00008267, "low": 0.0000816, "volume": 12.09695909596307, "adjusted": 0.0000816 },
        { "date": 1499031388, "close": 0.00008303, "open": 0.000083, "high": 0.0000837, "low": 0.00008294, "volume": 10.91308942290992, "adjusted": 0.00008294 }
    ]
}]

当我将图形的数据值指向 data2 时,它运行良好。但是当我指向 $scope.data.

时没有显示任何内容

编辑:这是 console.log

的结果
js[{"values":[{"date":1499034558,"close":0.00008388,"open":0.0000848,"high":0.0000848,"low":0.00008388,"volume":0.8672647004639618,"adjusted":0.00008388},{"date":1499034618,"close":0.00008405,"open":0.00008388,"high":0.00008574,"low":0.00008388,"volume":16.091108890994363,"adjusted":0.00008388},{"date":1499034678,"close":0.0000843,"open":0.00008405,"high":0.00008574,"low":0.00008388,"volume":2.3125435626714554,"adjusted":0.00008388},{"date":1499034738,"close":0.0000845,"open":0.0000843,"high":0.00008574,"low":0.00008388,"volume":0.012429811837685201,"adjusted":0.00008388}]}]
js2[{"values":[{"date":1499031328,"close":0.00008231,"open":0.0000816,"high":0.00008267,"low":0.0000816,"volume":12.09695909596307,"adjusted":0.0000816},{"date":1499031388,"close":0.00008303,"open":0.000083,"high":0.0000837,"low":0.00008294,"volume":10.91308942290992,"adjusted":0.00008294}]}]

添加

解决了
        $scope.$apply();
        $scope.api.refresh();

在 console.logs

之后

完美运行