Highcharts-ng不更新以反映基础数据

时间:2017-03-24 18:22:34

标签: javascript angularjs highcharts highcharts-ng

我遇到了Highcharts-ng最新版本(1.0)的问题:图表不再更新以反映基础数据。

Here's a Plunker demonstrating how it SHOULD work (highcharts-ng v0.0.13)

And here's a Plunker demonstrating what happens in the 1.0 release (nothing)

我查看过Highcharts-ng文档并且无法找到有关图表不再更新的任何信息。有没有人对如何解决这个问题有任何意见?

演示app控制器:

angular.module("app", ['highcharts-ng'])
  .controller("AppController", function($scope, $http) {
    $scope.title = "Click 'add a point' to see chart update";

    // Chart configuration object.
    $scope.chartConfig = {
      chart: {
        type: 'column'
      },
      series: [{
        data: [10, 15, 12, 8, 7],
        id: 'series1'
      }],
      title: {
        text: 'Hello'
      },
      xAxis: {

      }
    };

    $scope.addPoint = function(){
      $scope.chartConfig.series[0].data.push(Math.random());
    }
  })

1 个答案:

答案 0 :(得分:0)

您的plunkr使用的Highcharts 4.2.4还不支持chart.update()方法。 Highcharts-ng 1.x需要Highcharts 5 +。

    <script data-require="highcharts@*" src="https://code.highcharts.com/5/highcharts.js"></script>

示例:https://plnkr.co/edit/7rXbYUqoFpeRUnYmQaA9?p=preview