Fixed dynamic update of legend. Previously a new visible legend was added for each update. Now it is replaced.