Added logic to generate legend for doughnut charts.