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. Image for the cookie policy date

Apply different colors for uptrend and down trend in line (column) chart


Hi,

How to apply different colors for uptrend and down trend in line (column) chart

(eg)For the upward line chart the color should be red and for downward chart it should be green


when the chart is a straight line(not up or down) the color should be white

Regards,
Sivaprasad C

2 Replies

RC Rajesh C Syncfusion Team May 4, 2007 04:20 AM UTC

Hi Sivaprasad,

Thank you for using Syncfusion products.

I have applied different colors for up and down trend in line chart. Please refer to the following code snippet.

[ C# ]
void series1_PrepareStyle(object sender, ChartPrepareStyleInfoEventArgs args)
{
ChartSeries series = sender as ChartSeries;
if (series != null&& args.Index < series.Points.Count -1)
{
if (series.Points[args.Index].YValues[0] == series.Points[args.Index+1].YValues[0])
args.Style.Interior = new Syncfusion.Drawing.BrushInfo(Color.White );
else if (series.Points[args.Index].YValues[0] < series.Points[args.Index+1].YValues[0])
args.Style.Interior = new Syncfusion.Drawing.BrushInfo(Color.Red);
else
args.Style.Interior = new Syncfusion.Drawing.BrushInfo(Color.Green );

}

}

Also kindly take a look at the attached sample.

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

Please let me know if you have any queries.

Regards,
Rajesh C


SC Sivaprasad C May 4, 2007 09:16 AM UTC

Thanks Rajesh...You solved my problem :)

>Hi Sivaprasad,

Thank you for using Syncfusion products.

I have applied different colors for up and down trend in line chart. Please refer to the following code snippet.

[ C# ]
void series1_PrepareStyle(object sender, ChartPrepareStyleInfoEventArgs args)
{
ChartSeries series = sender as ChartSeries;
if (series != null&& args.Index < series.Points.Count -1)
{
if (series.Points[args.Index].YValues[0] == series.Points[args.Index+1].YValues[0])
args.Style.Interior = new Syncfusion.Drawing.BrushInfo(Color.White );
else if (series.Points[args.Index].YValues[0] < series.Points[args.Index+1].YValues[0])
args.Style.Interior = new Syncfusion.Drawing.BrushInfo(Color.Red);
else
args.Style.Interior = new Syncfusion.Drawing.BrushInfo(Color.Green );

}

}

Also kindly take a look at the attached sample.

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

Please let me know if you have any queries.

Regards,
Rajesh C


Loader.
Live Chat Icon For mobile
Up arrow icon