GraFiddle / angular-chart

AngularJS directive for adjustable dynamically updating c3 charts
http://grafiddle.github.io/angular-chart/
MIT License
127 stars 40 forks source link

Synchronizing "options" property #31

Closed ulilicht closed 9 years ago

ulilicht commented 9 years ago

Hi Max,

I tried your directive - but got some trouble when trying to dynamically modify the selections of a graph.

When selecting any point, it is added to the selections object of options. (sync c3 --> angular) but when I try to modify those selections in angular, they are not synced back. (e.g. removing an entry in the selections array)

I for example would expect this code to remove one element:

$scope.$watch('options.selection.selected', function (newVal, oldVal) {
      if (newVal.length > 2) {
        console.log('more than two values selected', $scope.options.selection.selected);
        $scope.options.selection.selected.shift(); 
       console.log('more than two values selected', $scope.options.selection.selected);
      }
    }, true);

Is there yet any possibility to achieve this?

maxklenk commented 9 years ago

Thank you very much, I merged your pull request.

Removing selections throw angular was already possible, but your fix now allows adding and removing selections at the same time.