开发者

Visual Studio 2010 Chart control - line color

How do I change the color of the horizonal and vertical lines? I'd like to make them a little lighter, yet leave the X and Y axis black, probably.

Visual Studio 2010 Chart control - line color

Edited:

indyfromoz suggestion resulted in this:

Visual Studio 2010 Chart control - line color

The effect I want is this:

Visual Studio 2010 Chart control - line color

(Subtler horiz and vertical lines, ma开发者_如何学编程ybe even no vertical lines.)


VB

Chart1.ChartAreas(0).AxisY.MajorGrid.LineColor = Color.FromArgb(&H50, &H9C, &H9A, &H95)
Chart1.ChartAreas(0).AxisX.MajorGrid.LineColor = Color.FromArgb(&H50, &H9C, &H9A, &H95)

C#

Chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = Color.FromArgb(50, 200, 200, 200);
Chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = Color.FromArgb(50, 200, 200, 200);


You have two options - use the Axis.IsInterlaced property or the Axis.StripLines property. This page is a handy reference for customization of the grid lines in a chart.

Here is some sample C# code (from the above reference) -

chart1.ChartAreas[0].AxisY.StripLines.Add(new StripLine()); 
chart1.ChartAreas[0].AxisY.StripLines[0].BackColor = Color.FromArgb(80, 252, 180, 65); 
chart1.ChartAreas[0].AxisY.StripLines[0].StripWidth = 40; 
chart1.ChartAreas[0].AxisY.StripLines[0].Interval = 10000; 
chart1.ChartAreas[0].AxisY.StripLines[0].IntervalOffset **

HTH, indyfromoz

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜