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.

Help w/ Line Chart

Thread ID:





70888 Jan 7,2008 03:13 PM Jan 10,2008 09:36 AM Windows Forms 5
Tags: Chart
Michael Sabin
Asked On January 7, 2008 03:13 PM

Hi, I was wondering if you can help me out. I would like to make a line chart that would display the following data:

Apple: 25
Orange: 45
Peach: 75
Grape: 15
Pear: 112

I would also like each item to have a different color. Can you please provide an example how I can do this.


SubhaSheela R [Syncfusion]
Replied On January 9, 2008 01:53 AM

Hi Michael,

Thank you for using for Syncfusion products.

We can give different colors to each of the items by passing the values for label name, color, font and ChartValueType parameters to the PrimaryXAxis's Label method. Please refer to the code snipept given below:

this.chartControl1.PrimaryXAxis.ValueType = ChartValueType.Custom;
this.chartControl1.PrimaryXAxis.TickLabelsDrawingMode = ChartAxisTickLabelDrawingMode.UserMode;
this.chartControl1.PrimaryXAxis.Labels.Add(new ChartAxisLabel("Apple", Color.Crimson, new Font("Monospace", 11), 0, "", ChartValueType.Custom));
this.chartControl1.PrimaryXAxis.Labels.Add(new ChartAxisLabel("Orange", Color.Blue, new Font("Monospace", 11), 1, "", ChartValueType.Custom));
this.chartControl1.PrimaryXAxis.Labels.Add(new ChartAxisLabel("Peach", Color.LightBlue, new Font("Monospace", 11), 2, "", ChartValueType.Custom));
this.chartControl1.PrimaryXAxis.Labels.Add(new ChartAxisLabel("Grape", Color.GreenYellow, new Font("Monospace", 11), 3, "", ChartValueType.Custom));
this.chartControl1.PrimaryXAxis.Labels.Add(new ChartAxisLabel("Pear", Color.Crimson, new Font("Monospace", 11), 4, "", ChartValueType.Custom));

Kindly have a look into the simple sample available in the link below that illustrates the same:

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

Please let me if you have any questions.

Subhasheela R

SubhaSheela R [Syncfusion]
Replied On January 9, 2008 01:59 AM

Hi Michael,

Sorry for the broken link. Here is the link:


Subhasheela R

Michael Sabin
Replied On January 9, 2008 10:36 AM

Sorry, when I said line chart, I really meant Bar Chart. Your example did help a little, but I would like to set a different color for each bar (not the label at the bottom). I tried to create a different Series for each object but that doesn't work correctly.


SubhaSheela R [Syncfusion]
Replied On January 10, 2008 01:14 AM

Hi Michael,

Sorry for the inconvenience caused.

We can give different colors to each of the bars by handling ChartPrepareStyleInfoHandlerEvent. Please refer to the code snippet given below:

void series_PrepareStyle(object sender, ChartPrepareStyleInfoEventArgs args)
ChartSeries series = sender as ChartSeries;
if (series != null)
if (args.Index == 0)
args.Style.Interior = new Syncfusion.Drawing.BrushInfo(Color.Red);
else if (args.Index == 1)
args.Style.Interior = new Syncfusion.Drawing.BrushInfo(Color.Green);
else if (args.Index == 2)
args.Style.Interior = new Syncfusion.Drawing.BrushInfo(Color.Blue);
else if (args.Index == 3)
args.Style.Interior = new Syncfusion.Drawing.BrushInfo(Color.Yellow);
else if (args.Index == 4)
args.Style.Interior = new Syncfusion.Drawing.BrushInfo(Color.Aqua);

Kindly have a look into the sample available in the link below and let me know if it helps:


Subhasheela R

Michael Sabin
Replied On January 10, 2008 09:36 AM

Thank you, that is just what I wanted.


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.