create legend
remove legend and selected fields when the switch is off