Grid Lines

GridLines are vertical and horizontal lines that are added in conjunction to the Tick Marks on the XAxis and the YAxis respectively. Adding Grid lines makes data in the chart easier to read and interpret. There are two types of Grid lines:

XAxisGridLines

XAxisGridLines are added vertically to the Plot Area. MajorGridLines are drawn for each MajorTickMark and MinorGridLines are drawn for each MinorTickMark on the XAxis. By default the XAxisGridLines are turned off.

The below code shows how to add XAxisGridLines:

Chart chart = new Chart(0, 0, 300, 200);
PlotArea plotArea = chart.PrimaryPlotArea;
plotArea.XAxes.DefaultNumericXAxis.MajorGridLines = new XAxisGridLines();
plotArea.XAxes.DefaultNumericXAxis.MinorGridLines = new XAxisGridLines();        
Dim MyChart As Chart = New Chart(0, 0, 300, 200)
Dim MyPlotArea = MyChart.PrimaryPlotArea
MyPlotArea.XAxes.DefaultNumericXAxis.MajorGridLines = New XAxisGridLines()
MyPlotArea.XAxes.DefaultNumericXAxis.MinorGridLines = New XAxisGridLines()  

YAxisGridLines

YAxisGridLines are added horizontally to the Plot Area. MajorGridLines are drawn for each MajorTickMark and MinorGridLines are drawn for each MinorTickMark on the YAxis. By default the YAxisGridLines are turned off.

The below code shows how to add YAxisGridLines:

Chart chart = new Chart(0, 0, 300, 200);
PlotArea plotArea = chart.PrimaryPlotArea;
plotArea.YAxes.DefaultNumericYAxis.MajorGridLines = new YAxisGridLines();
plotArea.YAxes.DefaultNumericYAxis.MinorGridLines = new YAxisGridLines();        
Dim MyChart As Chart = New Chart(0, 0, 300, 200)
Dim MyPlotArea = MyChart.PrimaryPlotArea
MyPlotArea.YAxes.DefaultNumericYAxis.MajorGridLines = New YAxisGridLines()
MyPlotArea.YAxes.DefaultNumericYAxis.MinorGridLines = New YAxisGridLines()

In this topic