Skip to main content
 首页 » 编程设计

c#之Syncfusion图表问题

2024年02月24日33mate10pro

我使用的是 Visual Studio 2008 SyncFusion Essential Studio 企业版 (WinForms) 7.203.0.20 版。

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

请您参考如下方法:

为折线图设置颜色:

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(对象发送者,ChartPrepareStyleInfoEventArgs args) { //使用Prepare样式事件为数据点指定不同的颜色 ChartSeries 系列 = 发件人为 ChartSeries; 如果(系列!=空) { 如果 (this.chartControl1.Series[0].Type.ToString() == "Line") { 如果(args.Index == 0) args.Style.Interior = new Syncfusion.Drawing.BrushInfo(Color.Red); 否则如果(args.Index == 1) args.Style.Interior = new Syncfusion.Drawing.BrushInfo(Color.Green); 否则如果(args.Index == 2) args.Style.Interior = new Syncfusion.Drawing.BrushInfo(Color.Blue); 否则如果(args.Index == 3) args.Style.Interior = new Syncfusion.Drawing.BrushInfo(Color.Yellow); 否则如果(args.Index == 4)

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

问候, 周杰伦