DateTimeScaleOptions.WorkdaysOnly Property
Specifies whether holidays and non-working days should be excluded from the axis scale.
Namespace: DevExpress.XtraCharts
Assembly: DevExpress.XtraCharts.v24.2.dll
NuGet Package: DevExpress.Charts
Declaration
[XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)]
public bool WorkdaysOnly { get; set; }
Property Value
Type | Description |
---|---|
Boolean | true to exclude non-working days from the axis scale; otherwise, false. |
Property Paths
You can access this nested property as listed below:
Object Type | Path to WorkdaysOnly |
---|---|
AxisBase |
|
Remarks
The WorkdaysOnly property is available for an axis if its scale type is date-time.
WorkdaysOnly = false | WorkdaysOnly = true |
---|---|
After the WorkdaysOnly property is enabled, the WorkdaysOptions property becomes available and you can specify non-working days, holidays and strict workdays for the 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, via the AxisBase.WorkdaysOnly and AxisBase.WorkdaysOptions properties.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/winforms-chart-exclude-weekends-and-holidays-from-the-axis-range
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)));
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the WorkdaysOnly property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.