DateTimeScaleOptions.WorkdaysOptions Property
Provides access to information about holidays and workdays to adjust the date-time axis scale.
Namespace: DevExpress.XtraCharts
Assembly: DevExpress.XtraCharts.v24.2.dll
NuGet Package: DevExpress.Charts
#Declaration
[PersistenceMode(PersistenceMode.InnerProperty)]
[XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)]
public WorkdaysOptions WorkdaysOptions { get; }
#Property Value
Type | Description |
---|---|
Workdays |
A Workdays |
#Property Paths
You can access this nested property as listed below:
Object Type | Path to Workdays |
---|---|
Axis |
|
#Remarks
Enable the WorkdaysOnly property to make the WorkdaysOptions property available.
Use the WorkdaysOptions property to specify non-working days, holidays, and strict workdays for the date-time axis scale.
You can also use the SkipRangesWithoutPoints property to skip axis ranges that do not have data points.
For more information, refer to the following topic: Data Aggregation.
The following example demonstrates how you can exclude weekends and holidays from the X-axis range:
#Example
This example demonstates how to exclude non-working days (weekdays and holidays) from an axis range, with the DateTimeScaleOptions.WorkdaysOnly and DateTimeScaleOptions.WorkdaysOptions
properties.
Note
A complete sample project is available at https://github.
using System;
using System.Windows.Forms;
using DevExpress.XtraCharts;
// ...
DateTimeScaleOptions dateTimeScaleOptions = ((XYDiagram)chartControl1.Diagram).AxisX.DateTimeScaleOptions;
// Enables workday options.
dateTimeScaleOptions.WorkdaysOnly = true;
// Specifies custom work days.
// In this example, Sunday is a work day and Saturday is a day off.
dateTimeScaleOptions.WorkdaysOptions.Workdays = Weekday.Sunday | Weekday.Monday | Weekday.Tuesday |
Weekday.Wednesday | Weekday.Thursday | Weekday.Friday;
// Specifies custom holidays.
// In this example, March 8th (Monday) is an additional holiday.
dateTimeScaleOptions.WorkdaysOptions.Holidays.Add(
new KnownDate("Custom Holiday", new DateTime(2021, 3, 8, 0, 0, 0, 0)));
// Specifies work days, which have priority over specified holidays.
// In this example, March 6th (Saturday) is an additional work day.
dateTimeScaleOptions.WorkdaysOptions.ExactWorkdays.Add(
new KnownDate("Community Work Day", new DateTime(2021, 3, 6, 0, 0, 0, 0)));