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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Help w/ Line Chart

Thread ID:





70888 Jan 7,2008 08:13 PM UTC Jan 10,2008 02:36 PM UTC WinForms 5
Tags: Chart
Michael Sabin
Asked On January 7, 2008 08:13 PM UTC

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 06:53 AM UTC

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 06:59 AM UTC

Hi Michael,

Sorry for the broken link. Here is the link:


Subhasheela R

Michael Sabin
Replied On January 9, 2008 03:36 PM UTC

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 06:14 AM UTC

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 02:36 PM UTC

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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon 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.Close Icon