Reputation: 15794
I'm using Visual Studio 2008, SyncFusion Essential Studio Enterprise Edition, (WinForms) version 7.203.0.20.
I was wondering if anyone can help me out on a small question: how can I specify a custom color for each line in my line chart?
Upvotes: 2
Views: 2657
Reputation: 86
To set color for line chart:
this.chartControl1.Series[0].Style.Interior = new BrushInfo(GradientStyle.Vertical, Color.Red, Color.Orange);
Here is a help link - http://www.syncfusion.com/support/kb/83/How-do-I-set-the-Interior-colors-for-the-chart-series-data-points
If you want individual connecting lines to be of different color, then you need to handle the ChartSeries.PrepareStyle event as below:
this.chartControl1.Series[0].PrepareStyle += new ChartPrepareStyleInfoHandler(series_PrepareStyle);
void series_PrepareStyle(object sender, ChartPrepareStyleInfoEventArgs args) { //Specifying different Colors for data points using Prepare style event ChartSeries series = sender as ChartSeries; if (series != null) { if (this.chartControl1.Series[0].Type.ToString() == "Line") { 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)
Regards, Jay
Upvotes: 5