Skip to main content

ManualTimeSpanScaleOptions.GridAlignment Property

Gets or sets the time-span measurement unit that defines the alignment of grid lines and axis labels.

Namespace: DevExpress.Xpf.Charts

Assembly: DevExpress.Xpf.Charts.v23.2.dll

NuGet Package: DevExpress.Wpf.Charts

Declaration

public TimeSpanGridAlignment GridAlignment { get; set; }

Property Value

Type Description
TimeSpanGridAlignment

A measurement unit that defines how to align the axis major grid lines and labels.

Available values:

Name Description
Millisecond

Specifies the millisecond measurement unit.

Second

Specifies the second measurement unit.

Minute

Specifies the minute measurement unit.

Hour

Specifies the hour measurement unit.

Day

Specifies the day measurement unit.

Remarks

The following images show charts with different grid alignments (GridSpacing is set to 1).

Value Image
GridAlignment = “Hour”
GridAlignment = “Day”

Disable the AutoGrid property before you specify GridAlignment.

Example

The following example shows how to group minute-by-minute data into data points with a greater measurement unit (“Hour”).

<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:TimeSpanExample"
        xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts" 
        x:Class="TimeSpanExample.MainWindow"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Window.DataContext>
        <local:ChartViewModel/>
    </Window.DataContext>
    <Grid>
        <dxc:ChartControl>
            <dxc:XYDiagram2D>
                <dxc:XYDiagram2D.AxisX>
                    <dxc:AxisX2D>
                        <dxc:AxisX2D.TimeSpanScaleOptions>
                            <dxc:ManualTimeSpanScaleOptions GridAlignment="Hour" 
                                                            GridSpacing="4"
                                                            MeasureUnit="Hour"
                                                            AggregateFunction="Average"
                                                            GridOffset="2"
                                                            AutoGrid="False"/>
                        </dxc:AxisX2D.TimeSpanScaleOptions>                           
                    </dxc:AxisX2D>
                </dxc:XYDiagram2D.AxisX>
                <!-- Other diagram settings. -->
            </dxc:XYDiagram2D>
        </dxc:ChartControl>
    </Grid>
</Window>
See Also