Add legend generation from data.