2

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

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

4

1 回答 1

5

为折线图设置颜色:

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

问候,杰伊

于 2010-04-22T21:54:42.807 回答