1

用例: 当数据从 api 发生变化时,$scope.data也会发生变化。我可以看到 html 中的数据变化。预计会更新旭日图。

下面是核心代码:

控制器:

var grabData=function(){
  $http.get('someApi').then(function success(response){
  $scope.options = {
        chart: {
            type: 'sunburstChart',
            width:450,
            height: 450,
            color: d3.scale.category20c(),
            duration: 250,
            mode: 'size',
            useInteractiveGuideline:true,
        }
    };
    $scope.config = {
        visible: true, // default: true
        disabled: false, // default: false
        refreshDataOnly: true, // default: true
        deepWatchOptions: true, // default: true
        deepWatchData: true, // default: true
        deepWatchDataDepth: 2, // default: 2
        debounce: 10 // default: 10
    };
        $scope.data = [];
        $scope.data.push({"name":"PORTFOLIO", "children":response.data});
    },function error(response){
      $scope.all = response.statusText;
  });};

HTML:

<div class="col-md-6 col-md-offset-1">
  <nvd3 options="options" data="data" config="config" class="with-3d-shadow with-transitions"></nvd3>
</div>

问题: 现在当数据从 api 发生变化时,$scope.data也会发生变化。我可以看到 html 中的数据变化。但是在我手动刷新页面之前,旭日图根本不会更新

4

1 回答 1

1

所以修复很简单,你必须通过 refreshDataOnly: false。

config="{refreshDataOnly: false}"在您的配置中-

<nvd3 options="options" data="sunburst" config="{refreshDataOnly: false}" class="with-3d-shadow with-transitions"></nvd3>

于 2016-07-21T12:38:48.620 回答