Nevron Forum

Series FillColor does not match with Specified FillStyle Color??

https://www.nevron.com/Forum/Topic6486.aspx

By Niranjan Singh - Wednesday, May 30, 2012

I have created Series with following fill style as:

chartSeries.FillStyle = new NColorFillStyle(Color.Red);


But,
Color fillColor = (chart.Series[i] as NSeries).FillStyle.GetPrimaryColor().ToColor();


When i compare this with this fillColor == Color.Red. It returns false.

Why these doesn't match, even i have converted return NColor object to Color using it's method ToColor().


Any Help will be appreciated.

Thanks in Advance.
By Nevron Support - Wednesday, May 30, 2012

Hi Niranjan,

You're comparing a named color with an explicitly specified color. To improve performance nevron controls rarely stroke .NET color instances - instead they simply store ARGB information, without names. The following .NET code also returns false as the name of the second color is "ffff0000":

bool result = (Color.Red == Color.FromArgb(255, 0, 0)); // result is false

By Niranjan Singh - Friday, June 8, 2012

Hi,

Thanks for your reply, i understand that what is going wrong.

Well i have solved this problem as:

Color x = (chart.Series[i] as NSeries).FillStyle.GetPrimaryColor().ToColor();
Color y = NColor.FromString(PreDefinedSeriesColors[i].Name).ToColor();

and comparison of x and y returns true.

Regards,
Niranjan