我正在使用Visual Studio 2008,SyncFusion Essential Studio企业版,(WinForms)版本7.203.0.20。
我想知道是否有人可以帮我解决一个小问题:如何为折线图中的每一行指定自定义颜色?
答案 0 :(得分:4)
设置折线图的颜色:
this.chartControl1.Series[0].Style.Interior = new BrushInfo(GradientStyle.Vertical, Color.Red, Color.Orange);
如果您希望各个连接线具有不同的颜色,则需要处理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)
此致 杰