Fix conditional logic for legend display.