Xceed Chart for WinForms v4.4 Documentation
Date Time Scale

Welcome to Xceed Chart for WinForms v4.4 > User Guide > Axes > Scaling > Date Time Scale

Date-time scale mode is often used as an alternative to the default scale mode (Dimension) of the PrimaryX and SecondaryX chart axes (for details, see StandardAxis Enumeration). When operating in this mode, the axes treat the values contained in the data series as date-time values. 

The properties of the date-time scale are controlled through an instance of the AxisScaleDateTime class, which is accessible through the DateTimeScale property of the Axis class. The AxisScaleDateTime class is a direct descendant of the AxisScaleValue class and inherits all its functionality. It also implements control over the following aspects of a date time scale:

Controlling Major Tick Generation in Date Time Scale Mode

The user can control the mode in which major ticks are generated with the help of the MajorTickMode property which is of type MajorTickModeDateTime and can accept the following values (for details, see MajorTickModeDateTime Enumeration): 

Manual
Auto

CustomStep

IrregularSteps

Months
 

The following is a description of these modes:

VB.NET  

' there is one chart created by default

Dim chart As Chart = CType(chartControl1.Charts(0), Chart)

Dim axis As Axis =   chart.Axis(StandardAxis.PrimaryX)

 

axis.ScaleMode = AxisScaleMode.DateTime

axis.DateTimeScale.MajorTickMode = MajorTickModeDateTime.Manual

axis.MajorTicks.Clear()

 

Dim dt As DateTime =  New DateTime(2003,1,21)

 

axis.MajorTicks.Add(dt.ToOADate())

dt = New DateTime(2003, 2, 1)

axis.MajorTicks.Add(dt.ToOADate())

dt = New DateTime(2003, 2, 25)

axis.MajorTicks.Add(dt.ToOADate())

C#  

// there is one chart created by default

Chart chart = (Chart)chartControl1.Charts[0];

Axis axis = chart.Axis(StandardAxis.PrimaryX);

 

axis.ScaleMode = AxisScaleMode.DateTime;

axis.DateTimeScale.MajorTickMode = MajorTickModeDateTime.Manual;

axis.MajorTicks.Clear();

 

DateTime dt = new DateTime(2003, 1, 21);

 

axis.MajorTicks.Add(dt.ToOADate());

dt = new DateTime(2003, 2, 1);

axis.MajorTicks.Add(dt.ToOADate());

dt = new DateTime(2003, 2, 25);

axis.MajorTicks.Add(dt.ToOADate());

VB.NET  

axis.DateTimeScale.MajorTickMode = MajorTickModeDateTime.Auto

axis.DateTimeScale.MaxTickCount = 10

C#  

axis.DateTimeScale.MajorTickMode = MajorTickModeDateTime.Auto;

axis.DateTimeScale.MaxTickCount = 10;

VB.NET  

axis.DateTimeScale.MajorTickMode = MajorTickModeDateTime.CustomStep

axis.DateTimeScale.CustomStep = New TimeSpan(20, 4, 3, 0)

C#  

axis.DateTimeScale.MajorTickMode = MajorTickModeDateTime.CustomStep;
axis.DateTimeScale.CustomStep = new TimeSpan(20, 4, 3, 0);

VB.NET  

axis.DateTimeScale.MajorTickMode = MajorTickModeDateTime.IrregularSteps

axis.DateTimeScale.CustomSteps.Clear()

axis.DateTimeScale.CustomSteps.Add(TimeSpan.FromDays(20))

axis.DateTimeScale.CustomSteps.Add(TimeSpan.FromDays(10))

axis.DateTimeScale.CustomSteps.Add(TimeSpan.FromDays(15))

C#  

axis.DateTimeScale.MajorTickMode = MajorTickModeDateTime.IrregularSteps;

axis.DateTimeScale.CustomSteps.Clear();

axis.DateTimeScale.CustomSteps.Add(TimeSpan.FromDays(20));

axis.DateTimeScale.CustomSteps.Add(TimeSpan.FromDays(10));

axis.DateTimeScale.CustomSteps.Add(TimeSpan.FromDays(15));

VB.NET  

axis.DateTimeScale.MajorTickMode = MajorTickModeDateTime.Months

axis.DateTimeScale.MonthsStep = 3

C#  

axis.DateTimeScale.MajorTickMode = MajorTickModeDateTime.Months;

axis.DateTimeScale.MonthsStep = 3;

 

Demonstration of the DateTime Major Tick modes
Manual Auto
Custom Step
(in this case 20 days)
Irregular Steps
(in this case 20, 30, 15 days)
Months
(note that the scale preserves the month end)

 

 

 

Related Examples

Windows Forms: Axes\Scaling\DateTime Scale

See Also

Axis | AxisScale | AxisScaleValue | AxisScaleDateTime