Check for invalid value when computing legend class