Show and hide legend based on which tab is selected