gonewandering / angles

An angular.js wrapper for Chart.js
MIT License
632 stars 87 forks source link

Legend duplicated when data changes #49

Open ethul opened 10 years ago

ethul commented 10 years ago

I tried out the new legend functionality, which looks great; however, when the data changes, the legend is repeatedly being inserted into the DOM.

See https://github.com/lgsilver/angles/blob/0859278e0c09fc28c08f02d72d79341004f9afe3/angles.js#L64-65

yangpu commented 10 years ago

yes, it does

adambutler commented 9 years ago

:+1:

fleurystephane commented 9 years ago

Is there a correction for this problem? Tkx

martypitt commented 9 years ago

:+1:

aldidas commented 9 years ago

I can solve this problem using this little hack in line 64 :

if($scope.legend) {
   angular.element($elem[0]).parent().parent().children('ul').remove();
   angular.element($elem[0]).parent().after( chartCreated.generateLegend() );
}

Hope this helps.

jmelosegui commented 8 years ago

:+1:

detinho commented 8 years ago

Can I make a pull request for this? I've used the correction proposed above and it worked well.