<...">

Angularjs - refresh `d3js` chart when data changes

I created a table directivefor my chart d3js:

html:
<donuts-chart chart-data="mydonuts" ></donuts-chart>

directive:
.directive('donutsChart', function ($parse) {
var donutobject = {
    restrict: 'E',
    replace: false, 
    scope: {data: '=chartData'},
    link: function (scope, element, attrs) {

      scope.$watch('data', function(newVals, oldVals) {
        console.log('there is new data');
      }, true);

          };
    return donutobject;
   })

I add scope.$watchonly to check if the information is updated. But that does not work. How can I make this work? I need to update the chart whenever new data appears.

+4
source share

Source: https://habr.com/ru/post/1621909/


All Articles