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:
- Manual: When operating in this mode, the scale does not produce any ticks. It is up to the user to specify values on which major ticks should be displayed. The following code displays ticks on these date-time values: 21/1/2003, 1/2/2003, and 25/2/2003 of the PrimaryX axis:
VB.NET | |
---|---|
|
C# | |
---|---|
|
- Auto: Automatic mode produces automatic major ticks at equal intervals. The step is automatically determined. In this mode the user can control the density of the automatically generated major ticks with the help of the MaxTickCount property (inherited from AxisScaleValue). The following code instructs the PrimaryY axis to operate in Auto mode and generate no more than 10 major ticks regardless of the data scaled on it.
VB.NET | |
---|---|
|
C# | |
---|---|
|
- Custom Step: Custom step mode produces automatic major ticks at equal intervals with user specified step. The step is controlled by the CustomStep property which is of type TimeSpan. The following code will force the date-time scale to produce major ticks with a step of 20 days, 4 hours and 3 minutes.
VB.NET | |
---|---|
|
C# | |
---|---|
|
- Irregular Steps: In this scaling mode, the scale produces automatic major ticks at irregular intervals. The user specifies a steps array through which the scale iterates. The following code will generate major ticks at irregular user defined intervals:
VB.NET | |
---|---|
|
C# | |
---|---|
|
- Months: In this mode, the scale produces automatic major ticks at month intervals. The user specifies the month step with the MonthsStep property.
This scale mode will preserve the month ends. For example, if the scale begins at 1/31/2003 (end of January) and MonthsStep is set to 1, the generated ticks will be:
1/31/2003, 2/28/2003 (end of February), 3/31/2003 (end of March), 4/30/2003 (end of April) ...
On the other hand, if the scale begins at 1/30/2003 (not the month end), the generated ticks will be:
1/30/2003, 2/28/2003 (day clamped to largest possible), 3/28/2003 (only month increased), 4/28/2003 (only month increased) ...
The following code instructs the date time scale to generate ticks on each third month:
VB.NET | |
---|---|
|
C# | |
---|---|
|
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