add formatter for legend

refined as advised, thanks.