Back to Devexpress

NumericScaleOptions.GridAlignmentStartPoint Property

corelibraries-devexpress-dot-xtracharts-dot-numericscaleoptions-7af96256.md

latest4.5 KB
Original Source

NumericScaleOptions.GridAlignmentStartPoint Property

Specifies the start point for aligning the scale along the x-axis.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
public NumericStartPoint GridAlignmentStartPoint { get; set; }
vb
Public Property GridAlignmentStartPoint As NumericStartPoint

Property Value

TypeDescription
NumericStartPoint

The start point for aligning the scale along the x-axis.

|

Available values:

NameDescription
Zero

The alignment of the chart x-axis scale starts at zero.

| | MinRangeValue |

The alignment of the chart x-axis scale starts at the specified Range.MinValue property value.

|

Property Paths

You can access this nested property as listed below:

Object TypePath to GridAlignmentStartPoint
AxisBase

.NumericScaleOptions .GridAlignmentStartPoint

|

Remarks

The example below illustrates the use of the GridAlignmentStartPoint property.

When you select the NumericStartPoint.Zero property value, the x-axis scale alignment starts at zero:

When you select NumericStartPoint.MinRangeValue property value, the the x-axis scale alignment starts at the specified Range.MinValue property value:

The following code configures the axis scale settings to resemble the chart above:

csharp
using DevExpress.XtraCharts;
using System;
using System.Windows.Forms;

namespace ApplicationSample {
    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.NumericScaleOptions.AutoGrid = false;
            diagram.AxisX.WholeRange.MinValue = 1;
            diagram.AxisX.NumericScaleOptions.CustomGridAlignment = 1.31;
            diagram.AxisX.NumericScaleOptions.GridAlignment = NumericGridAlignment.Custom;
            diagram.AxisX.WholeRange.SideMarginsValue = 0;
            diagram.AxisY.WholeRange.AlwaysShowZeroLevel = true;
        }
        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;
        }

        private void startFromZero_Click(object sender, EventArgs e){
            XYDiagram diagram = chart.Diagram as XYDiagram;
            diagram.AxisX.NumericScaleOptions.GridAlignmentStartPoint = NumericStartPoint.Zero;
        }

        private void startFromMinValue_Click(object sender, EventArgs e){
            XYDiagram diagram = chart.Diagram as XYDiagram;
            diagram.AxisX.NumericScaleOptions.GridAlignmentStartPoint = NumericStartPoint.MinRangeValue;
        }
    }
}
vb
Public Class CountDistinctCustomAggregate
    Implements ICustomAggregate
End Class

See Also

NumericScaleOptions Class

NumericScaleOptions Members

DevExpress.XtraCharts Namespace