Back to Devexpress

Axis.MajorGridlines Property

officefileapi-devexpress-dot-spreadsheet-dot-charts-dot-axis-ba001452.md

latest3.4 KB
Original Source

Axis.MajorGridlines Property

Provides access to settings used to draw the major gridlines on the chart.

Namespace : DevExpress.Spreadsheet.Charts

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
ChartLineOptions MajorGridlines { get; }
vb
ReadOnly Property MajorGridlines As ChartLineOptions

Property Value

TypeDescription
ChartLineOptions

A ChartLineOptions object containing chart line display options.

|

Remarks

Major gridlines represent a series of horizontal or vertical lines drawn across an axis from its major tick marks through the entire plot area. Use the MajorGridlines property to display and format major gridlines for the specified axis.

To add minor gridlines to the chart and adjust their appearance, use the Axis.MinorGridlines property.

Example

The example below demonstrates how to create a simple line chart and display major gridlines for the category axis and the minor gridlines for the value axis by setting the ChartLineOptions.Visible property to true.

View Example

csharp
Worksheet worksheet = workbook.Worksheets["chartTask5"];
workbook.Worksheets.ActiveWorksheet = worksheet;

// Create a chart and specify its location.
Chart chart = worksheet.Charts.Add(ChartType.Line, worksheet["B2:C8"]);
chart.TopLeftCell = worksheet.Cells["F2"];
chart.BottomRightCell = worksheet.Cells["L15"];

// Display the major gridlines of the category axis.
chart.PrimaryAxes[0].MajorGridlines.Visible = true;
// Display the minor gridlines of the value axis.
chart.PrimaryAxes[1].MinorGridlines.Visible = true;

// Hide the legend.
chart.Legend.Visible = false;
vb
Dim worksheet As Worksheet = workbook.Worksheets("chartTask5")
workbook.Worksheets.ActiveWorksheet = worksheet

' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.Line, worksheet("B2:C8"))
chart.TopLeftCell = worksheet.Cells("F2")
chart.BottomRightCell = worksheet.Cells("L15")

' Display the major gridlines of the category axis.
chart.PrimaryAxes(0).MajorGridlines.Visible = True
' Display the minor gridlines of the value axis.
chart.PrimaryAxes(1).MinorGridlines.Visible = True

' Hide the legend.
chart.Legend.Visible = False

See Also

MinorGridlines

Axis Interface

Axis Members

DevExpress.Spreadsheet.Charts Namespace