Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

TimeSpanChartRangeControlClient.GridAlignment Property

Gets or sets the time-span measurement unit to which the chart’s gridlines and labels should be aligned.

Namespace: DevExpress.Xpf.Charts.RangeControlClient

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

NuGet Package: DevExpress.Wpf.Charts

#Declaration

public TimeSpanGridAlignment GridAlignment { get; set; }

#Property Value

Type Description
TimeSpanGridAlignment

A TimeSpanGridAlignment enumeration value that represents the measurement unit to which the chart’s gridlines and labels should be aligned.

Available values:

Name Description
Millisecond

Specifies a millisecond as the time-span unit to which axis grid lines should be aligned.

Second

Specifies a second as the time-span unit to which axis grid lines should be aligned.

Minute

Specifies a minute as the time-span unit to which axis grid lines should be aligned.

Hour

Specifies an hour as the time-span unit to which axis grid lines should be aligned.

Day

Specifies a day as the time-span unit to which axis gridlines should be aligned.

Auto

The time-span unit to which axis gridlines should be aligned is calculated automatically.

#Remarks

The GridAlignment option is in effect if the ChartRangeControlClientBase.ShowGridLines property is set to true.

The following images demonstrate the GridAlignment property in action.

GridAlignment = Hour, GridSpacing = 4 GridAlignment = Hour, GridSpacing = 8

#Example

This example demonstrates how to use the time-span chart client for a range control to display a chart with time-span data within the range control’s viewport.

In this example, a time-span chart range control client is bound to a System.Collections.Generic.List containing DataSourceItem objects.

Each DataSourceItem object contains Argument and Value properties, to which a time-span chart range control client is bound via its ChartRangeControlClient.ArgumentDataMember and ChartRangeControlClient.ValueDataMember properties.

using System;
using System.Collections.Generic;
using System.Windows;
namespace TimeSpanChartRangeControlClient {
    public class DataSourceItem {
        public object Argument { get; set; }
        public object Value { get; set; }
    }
    public partial class MainWindow : Window {
        const int dataCount = 100;
        List<DataSourceItem> data = new List<DataSourceItem>();
        List<DataSourceItem> GenerateDateTimeData() {
            List<DataSourceItem> data = new List<DataSourceItem>();
            Random rand = new Random();
            double value = 0;
            for (int i = 0; i < dataCount; i++) {
                value += (rand.NextDouble() - 0.5);
                data.Add(new DataSourceItem() { Argument = TimeSpan.FromMinutes(i * 30),
                                                Value = Math.Abs(value + Math.Sin(i * 0.6)) });
            }
            return data;
        }
        public MainWindow() {
            InitializeComponent();
            this.DataContext = GenerateDateTimeData();
        }
    }
}
See Also