Syncfusion图表问题

时间:2010-04-22 19:16:41

标签: c# winforms syncfusion

我正在使用Visual Studio 2008,SyncFusion Essential Studio企业版,(WinForms)版本7.203.0.20。

我想知道是否有人可以帮我解决一个小问题:如何为折线图中的每一行指定自定义颜色?

1 个答案:

答案 0 :(得分:4)

设置折线图的颜色:

this.chartControl1.Series[0].Style.Interior = new BrushInfo(GradientStyle.Vertical, Color.Red, Color.Orange);

这是一个帮助链接 - http://www.syncfusion.com/support/kb/83/How-do-I-set-the-Interior-colors-for-the-chart-series-data-points

如果您希望各个连接线具有不同的颜色,则需要处理ChartSeries.PrepareStyle事件,如下所示:

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)

http://samples.syncfusion.com/sfwinsamples82/Chart.Windows/Chart%20Types/Line%20Charts/Sample.aspx?args=1

此致 杰