Kendo + Angular chart data

后端 未结 3 1806
长发绾君心
长发绾君心 2020-12-30 15:49

I\'m trying out Kendo charts with angular, and I have problem displaying data, here is my code:

HTML:

3条回答
  •  情书的邮戳
    2020-12-30 16:24

    I think your problem is that $scope.chartOptions is set before the data of the resultService is retrieved. Angular is returning an empty array in this case and filling in the data later. But $scope.chartOptions not not updated with new data.

    You could try with

    $scope.$watchCollection('oldReps', function(newData, oldData) {
      $scope.chartOptions.series[0].data = newData;
    });
    $scope.$watchCollection('newReps', function(newData, oldData) {
      $scope.chartOptions.series[1].data = newData;
    });
    

    So chartOptions are updated if oldReps or newReps have changed.

    I had a similiar problem and $watchCollection saved my day (Caching data and updating another object for an chart does not work)

提交回复
热议问题