We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Custom Color setting

Thread ID:

Created:

Updated:

Platform:

Replies:

57982 Mar 15,2007 06:40 AM Mar 21,2007 02:33 AM ASP.NET Web Forms (Classic) 3
loading
Tags: Chart
Bruce Smith
Asked On March 15, 2007 06:40 AM

Is there any way to change the pie segments colors so that they are a solid block of color without the light effect on it. I've

I quite like the effect but the end customer has asked whether the control can do it in this format as well.

Thanks.

example23.zip

Administrator [Syncfusion]
Replied On March 15, 2007 02:34 PM

Hi Anon,

Thank you for using Syncfusion products.

You can set the pie segments colors without Gradient effect. I have changed pie segments colors in PrepareStyle event. Please refer to the following code snippet.

[ C# ]

void series1_PrepareStyle(object sender, ChartPrepareStyleInfoEventArgs args)
{
ChartSeries series = sender as ChartSeries;
if (series != null)
{
if (args.Index == 0)
args.Style.Interior = new BrushInfo(Color.Blue);
else if (args.Index == 1)
args.Style.Interior = new BrushInfo(Color.Aquamarine);
}
}

Please have a look at this sample and let me know if this helps you.

http://websamples.syncfusion.com/samples/Chart.Windows/F57982/main.htm

Regards,
Rajesh

Bruce Smith
Replied On March 20, 2007 06:06 AM

Thanks for that. It was what I was after.

As a result I have another question. If for the pie chart OptomizePiePointPostions is set to true then the control decides on the positioning of the segment. Is there any way to get this order through the prepare style event. I can get the index of the data item but that does not give me the relative order it is shown in the pie chart. The reason why I ask is this is needed for setting the custom color for the segment to ensure the colors next to it do not clash.

Ramya R [Syncfusion]
Replied On March 21, 2007 02:33 AM

Hi Anon,

Thank You for the update.

If your intention is to make sure that the Colors of a segment do not match with nearby segments then it can be done by checking the index values of each segment and setting colors as in the previous update. Kindly take a look at the code snippets below,

private void series1_PrepareStyle(object sender, ChartPrepareStyleInfoEventArgs args)
{
ChartSeries series = sender as ChartSeries;
if (series != null)
{
if (args.Index == 0)
args.Style.Interior = new BrushInfo(Color.Blue);
else if (args.Index == 1)
args.Style.Interior = new BrushInfo(Color.Aquamarine);
}
}

(or)



private void series1_PrepareStyle(object sender, ChartPrepareStyleInfoEventArgs args)
{
ChartSeries series = sender as ChartSeries;
if (series != null)
{
if (args.Index == this.ChartWebControl1.Series[0].Points.IndexOf(this.ChartWebControl1.Series[0].Points[0]))
args.Style.Interior = new BrushInfo(Color.Blue
else if (args.Index == this.ChartWebControl1.Series[0].Points.IndexOf(this.ChartWebControl1.Series[0].Points[1]))
args.Style.Interior = new BrushInfo(Color.Aquamarine);
}
}

Let me know if I am wrong in getting your requirement.

Thanks & Regards,
Ramya.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;