corelibraries-devexpress-dot-xtracharts-dot-scalegridoptionsbase-9a4ce2a5.md
Gets or sets the offset of grid lines and major tickmarks.
Namespace : DevExpress.XtraCharts
Assembly : DevExpress.XtraCharts.v25.2.dll
NuGet Package : DevExpress.Charts
[XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)]
public double GridOffset { get; set; }
<XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)>
Public Property GridOffset As Double
| Type | Description |
|---|---|
| Double |
The grid offset.
|
You can shift the specified major tickmarks and grid lines with the GridOffset property.
Initially, the ScaleGridOptionsBase.AutoGrid property is set to true and GridOffset is calculated automatically. If you specify the grid offset, AutoGrid is set to false.
The example below illustrates the use of GridOffset. GridOffset that is set to 1 shifts the major tickmarks in one numeric value.
using DevExpress.XtraCharts;
using System;
using System.Collections.Generic;
using System.Data;
using System.Windows.Forms;
namespace AggregationSample {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) {
chart.Series.Add(GenerateSeries(20));
XYDiagram diagram = chart.Diagram as XYDiagram;
if (diagram == null) return;
diagram.AxisX.NumericScaleOptions.ScaleMode = ScaleMode.Manual;
diagram.AxisX.WholeRange.SideMarginsValue = 0;
diagram.AxisX.NumericScaleOptions.GridSpacing = 2;
diagram.AxisX.NumericScaleOptions.GridOffset = 1;
}
Series GenerateSeries(int pointCount) {
Series series = new Series {
Name = "Random data",
View = new SideBySideBarSeriesView()
};
Random generator = new Random();
for (int i = 0; i < pointCount; ++i) {
series.Points.Add(new SeriesPoint((i), generator.Next(10)));
}
return series;
}
}
}
Imports DevExpress.XtraCharts
Imports System
Imports System.Collections.Generic
Imports System.Data
Imports System.Windows.Forms
Namespace AggregationSample
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
chart.Series.Add(GenerateSeries(20))
Dim diagram As XYDiagram = TryCast(chart.Diagram, XYDiagram)
If diagram Is Nothing Then
Return
End If
diagram.AxisX.NumericScaleOptions.ScaleMode = ScaleMode.Manual
diagram.AxisX.WholeRange.SideMarginsValue = 0
diagram.AxisX.NumericScaleOptions.GridSpacing = 2
diagram.AxisX.NumericScaleOptions.GridOffset = 1
End Sub
Private Function GenerateSeries(ByVal pointCount As Integer) As Series
Dim series As Series = New Series With {
.Name = "Random data",
.View = New SideBySideBarSeriesView()
}
Dim generator As New Random()
For i As Integer = 0 To pointCount - 1
series.Points.Add(New SeriesPoint((i), generator.Next(10)))
Next i
Return series
End Function
End Class
End Namespace
For date-time axes, the GridOffset property value is expressed in GridAlignment units.
For example, if the DateTimeScaleOptions.GridAlignment property is set to DateTimeGridAlignment.Month, GridOffset that is set to 1 shifts the major tickmarks in one month:
Review the following demo for the example of how to set GridOffset for date-time axes:
Run Demo: XtraCharts MainDemo — Date-Time Scale
See Also
Grid Lines, Tickmarks and Interlacing