Skip to main content

ScaleGridOptionsBase.GridOffset Property

Gets or sets the offset of grid lines and major tickmarks.

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v23.2.dll

NuGet Package: DevExpress.Charts

Declaration

[XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)]
public double GridOffset { get; set; }

Property Value

Type Description
Double

The grid offset.

Remarks

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.

Numeric Axes

The example below illustrates the use of GridOffset. GridOffset that is set to 1 shifts the major tickmarks in one numeric value.

Offset Numeric Axes

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;
        }
    }
}

Date-Time Axes

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:

Offset Date-Time example

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