Skip to main content

DateTimeScaleOptions.WorkdaysOptions Property

Provides access to the information about non-working days to adjust the date-time axis scale.

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v24.1.dll

NuGet Package: DevExpress.Charts

Declaration

[PersistenceMode(PersistenceMode.InnerProperty)]
[XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)]
[XtraSerializableProperty(XtraSerializationVisibility.Content)]
public WorkdaysOptions WorkdaysOptions { get; }

Property Value

Type Description
WorkdaysOptions

A WorkdaysOptions object that contains information about non-working days.

Property Paths

You can access this nested property as listed below:

Object Type Path to WorkdaysOptions
AxisBase
.DateTimeScaleOptions .WorkdaysOptions

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:

View Example: Charts - How to exclude weekends and holidays from the axis range

Example

This example demonstates how to exclude non-working days (weekdays and holidays) from an axis range, via the AxisBase.WorkdaysOnly and AxisBase.WorkdaysOptions properties.

using System;
using System.Windows.Forms;
using DevExpress.XtraCharts;
// ...
AxisX axisX = ((XYDiagram)chartControl1.Diagram).AxisX;

// Exclude holidays from the axis scale.
axisX.WorkdaysOnly = true;

// Specify custom working days.
axisX.WorkdaysOptions.Workdays = Weekday.Sunday | Weekday.Monday | Weekday.Tuesday |
    Weekday.Wednesday | Weekday.Thursday | Weekday.Friday;

// Specify holidays
axisX.WorkdaysOptions.Holidays.AddRange(new KnownDate[] {
    new KnownDate("Custom Holiday 1", new DateTime(1994, 3, 2, 0, 0, 0, 0)),
    new KnownDate("Custom Holiday 2", new DateTime(1994, 4, 2, 0, 0, 0, 0))});

// Specify strict working days.
// Thay will have a priority over the holidays specified.
axisX.WorkdaysOptions.ExactWorkdays.Add(
    new KnownDate("Community Work Day", new DateTime(1994, 3, 2, 0, 0, 0, 0)));
See Also