Back to Devexpress

Work Time and Workday Configuration

wpf-116192-controls-and-libraries-charts-suite-chart-control-provide-data-work-time-and-workday-configuration.md

latest8.1 KB
Original Source

Work Time and Workday Configuration

  • Nov 23, 2025
  • 3 minutes to read

This document explains how to exclude non-working days and time from the date-time x-axis scale.

Exclude Non-Working Days

Workdays Options allow you to exclude non-working days or add strict workdays.

DateTimeScaleOptionsBase.WorkdaysOnly = falseDateTimeScaleOptionsBase.WorkdaysOnly = true

The following markup shows how to configure the workdays options.

xaml
<dxc:XYDiagram2D.AxisX>
    <dxc:AxisX2D>
        <dxc:AxisX2D.DateTimeScaleOptions>
            <!-- Enable the capability to exclude non-working days from the date-time axis. -->
            <dxc:ManualDateTimeScaleOptions WorkdaysOnly="True">
                <dxc:ManualDateTimeScaleOptions.WorkdaysOptions>
                    <!-- Specify which days of the week are treated as workdays. -->
                    <dxc:WorkdaysOptions Workdays="Monday,Tuesday,Wednesday,Thursday,Friday"
                                         <!-- Specify dates which are treated as non-working days. -->
                                         Holidays="01/01/2017,01/02/2017" 
                                         <!-- Specify exact dates of workdays. -->
                                         ExactWorkdays="01/21/2017"/>
                </dxc:ManualDateTimeScaleOptions.WorkdaysOptions>
            </dxc:ManualDateTimeScaleOptions>
        </dxc:AxisX2D.DateTimeScaleOptions>
        <!--...-->
    </dxc:AxisX2D>
</dxc:XYDiagram2D.AxisX>

The markup above uses the following classes and properties to specify workdays.

Class or PropertyDescription
DateTimeScaleOptionsBase.WorkdaysOnlySpecifies whether holidays and non-working days should be excluded from the date-time axis scale.
DateTimeScaleOptionsBase.WorkdaysOptionsSpecifies information about non-working days.
WorkdaysOptionsThe settings that specify holidays and workdays for the date-time axis scale.
WorkdaysOptions.WorkdaysSpecifies which days of the week are workdays.
WorkdaysOptions.HolidaysSpecifies holiday dates for excluding them from the date-time scale.
WorkdaysOptions.ExactWorkdaysSpecifies strict workday dates for including them in the date-time scale.

Note that instead of manually specifying holiday dates, you can import them from the DevExpress Scheduler ( .xml ) or Microsoft Office Outlook® ( .hol ) file using the WorkdaysOptions.LoadHolidays method.

You can use the DateTimeAggregationScaleOptionsBase.SkipRangesWithoutPoints property to exclude all date-time axis ranges without data points.

Exclude Non-Working Time

Work Time Rules allow you to specify time intervals which should be displayed on the date-time axis. The following table demonstrates this feature in action.

DateTimeScaleOptionsBase.WorkTimeOnly = falseDateTimeScaleOptionsBase.WorkTimeOnly = true

The following markup shows how to configure work time options.

xaml
<dxc:XYDiagram2D.AxisX>
    <dxc:AxisX2D>
        <dxc:AxisX2D.DateTimeScaleOptions>
            <!-- Enable the feature to show only working time on the date-time x-axis. -->
            <dxc:ManualDateTimeScaleOptions WorkTimeOnly="True"
                                            AutoGrid="False"                              
                                            MeasureUnit="Hour" 
                                            GridAlignment="Hour">
                <dxc:ManualDateTimeScaleOptions.WorkTimeRules>
                    <!-- Add a work time rule. -->
                    <!-- Specify weekdays on which this rule should be applied. -->
                    <dxc:WorkTimeRule Weekdays="Monday,Tuesday,Wednesday,Thursday,Friday">
                        <dxc:WorkTimeRule.WorkIntervals>
                            <!-- Specify one or more working time intervals of this rule. -->
                            <dxc:TimeInterval StartHour="09"
                                              StartMinute="00"
                                              StartSecond="00"
                                              EndHour="18"
                                              EndMinute="00"
                                              EndSecond="00"/>
                        </dxc:WorkTimeRule.WorkIntervals>
                    </dxc:WorkTimeRule>
                    <!-- Add one more work time rule. -->
                    <!-- Specify the date to which the rule is applied. -->
                    <dxc:WorkTimeRule Date="02/02/17">
                        <dxc:WorkTimeRule.WorkIntervals>
                            <!-- A time interval can be set as follows. -->
                            <dxc:TimeInterval>9:00:00-18:00:00</dxc:TimeInterval>
                        </dxc:WorkTimeRule.WorkIntervals>
                    </dxc:WorkTimeRule>
                </dxc:ManualDateTimeScaleOptions.WorkTimeRules>
            </dxc:ManualDateTimeScaleOptions>
        </dxc:AxisX2D.DateTimeScaleOptions>
        <!--...-->
    </dxc:AxisX2D>
</dxc:XYDiagram2D.AxisX>

Note

For weekdays whose work time rules are not specified (e.g., Saturday and Sunday in the code above), the whole day (00:00 AM - 12:00 PM) is considered as work time.

The markup above uses the following classes and properties to specify work time.

Class or PropertyDescription
DateTimeScaleOptionsBase.WorkTimeOnlySpecifies whether to show only the working time on the date-time axis.
DateTimeScaleOptionsBase.WorkTimeRulesSpecifies a collection of work time rules which should be applied to the date-time axis scale.
WorkTimeRuleSpecifies a work time rule.
WorkTimeRule.WeekdaysSpecifies weekdays on which the specified working time intervals should be applied.
WorkTimeRule.DateSpecifies the date on which a rule should be applied.
WorkTimeRule.WorkIntervalsSpecifies working time intervals within a day.
TimeIntervalSpecifies a time interval.
TimeInterval.StartHourSpecifies the hour part of the time interval’s start.
TimeInterval.StartMinuteSpecifies the minute part of the time interval’s start.
TimeInterval.StartSecondSpecifies the second part of the time interval’s start.
TimeInterval.EndHourSpecifies the hour part of the time interval’s end.
TimeInterval.EndMinuteSpecifies the minute part of the time interval’s end.
TimeInterval.EndSecondSpecifies the second part of the time interval’s end.

See Also

Data Aggregation