1👍
✅
You need to clear your chart1Legend
first before your append your legend.
Try the below snippet.
$('#chart1Legend').empty();
$('#chart1Legend').append(legend);
Hope this helps!
Source:stackexchange.com