Fixed dynamic update of legend

Previously a new visible legend was added for each update. Now it is replaced.
Please pull this fix.

Best regards,
Michiel