This is a migrated thread and some comments may be shown as answers.

pie chart color should change for each and every series

1 Answer 150 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Gokul
Top achievements
Rank 1
Gokul asked on 14 May 2013, 08:52 AM
Hi,
  I'm Having Pie Chart by using stored procedure i will bind the values in chart for that chart series i want to change color (i have 5 series)
   for every series the color should vary.
Thanks

1 Answer, 1 is accepted

Sort by
0
Accepted
Rosko
Telerik team
answered on 17 May 2013, 08:57 AM
Hi Gokul,

I hope I understand this right -- for each pie series you want to have different set of colors. What you need to do is to iterate through each item in each series.

ChartSeries series1 = new ChartSeries();
 
series1.Type = ChartSeriesType.Pie;
series1.AddItem(120, "Internet");
series1.AddItem(140, "Retail");
series1.AddItem(35, "Wholesale");
 
Color[] colors = (new Color[3]
    {
        Color.Red,
        Color.Green,
        Color.Blue,
    });
 
for (int i = 0; i < series1.Items.Count; i++)
{
    series1.Items[i].Appearance.FillStyle.MainColor = colors[i];
}


Greetings,
Rosko
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Chart (Obsolete)
Asked by
Gokul
Top achievements
Rank 1
Answers by
Rosko
Telerik team
Share this question
or