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.

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

Thread ID:

Created:

Updated:

Platform:

Replies:

60362 May 3,2007 07:31 AM May 4,2007 05:16 AM Windows Forms 2
loading
Tags: Chart
Sivaprasad C
Asked On May 3, 2007 07:31 AM


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

Rajesh C [Syncfusion]
Replied On May 4, 2007 12:20 AM

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

Sivaprasad C
Replied On May 4, 2007 05:16 AM

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


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.

;