2016-07-04 45 views
0

我想使用AngularJS動態更新Chartjs圖表的數據。如果沒有數據被更新,圖表工作正常,但如果我嘗試使用$ interval函數更新數據,圖表只是空白。

$scope.labelsx2 = []; 
    $scope.seriesx2 = []; 
    $scope.datax2 = [ 
     [65, 59, 80, 81, 56, 55, 40] 
    ]; 

    $scope.randomize = function() { 


     $scope.datax2 = [65, 59, 1, 81, 1, 55, 1]; 
     console.log('workk'); 


    }; 

    $interval(function() {$scope.randomize();},1000,0); 


    <div class="item item-text-wrap"> 

     <canvas id="line" class="chart chart-line" data="datax2" labels="labelsx2" legend="true" series="seriesx2" options="{showTooltips: false}"></canvas> 

    </div> 

回答

0

變化

$scope.datax2 = [65, 59, 1, 81, 1, 55, 1]; 

在隨機化功能與

$scope.datax2 = [[65, 59, 1, 81, 1, 55, 1]];