fix toggle bug in legend