legend changes on click