Skip to main content

Work Time and Workday Configuration

  • 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 = false DateTimeScaleOptionsBase.WorkdaysOnly = true
WorkdaysOnly_false WorkdaysOnly_true

The following markup shows how to configure the workdays options.

<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 Property Description
DateTimeScaleOptionsBase.WorkdaysOnly Specifies whether holidays and non-working days should be excluded from the date-time axis scale.
DateTimeScaleOptionsBase.WorkdaysOptions Specifies information about non-working days.
WorkdaysOptions The settings that specify holidays and workdays for the date-time axis scale.
WorkdaysOptions.Workdays Specifies which days of the week are workdays.
WorkdaysOptions.Holidays Specifies holiday dates for excluding them from the date-time scale.
WorkdaysOptions.ExactWorkdays Specifies 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 = false DateTimeScaleOptionsBase.WorkTimeOnly = true
WorkTimeOnly_false WorkTimeOnly_true

The following markup shows how to configure work time options.

<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 Property Description
DateTimeScaleOptionsBase.WorkTimeOnly Specifies whether to show only the working time on the date-time axis.
DateTimeScaleOptionsBase.WorkTimeRules Specifies a collection of work time rules which should be applied to the date-time axis scale.
WorkTimeRule Specifies a work time rule.
WorkTimeRule.Weekdays Specifies weekdays on which the specified working time intervals should be applied.
WorkTimeRule.Date Specifies the date on which a rule should be applied.
WorkTimeRule.WorkIntervals Specifies working time intervals within a day.
TimeInterval Specifies a time interval.
TimeInterval.StartHour Specifies the hour part of the time interval’s start.
TimeInterval.StartMinute Specifies the minute part of the time interval’s start.
TimeInterval.StartSecond Specifies the second part of the time interval’s start.
TimeInterval.EndHour Specifies the hour part of the time interval’s end.
TimeInterval.EndMinute Specifies the minute part of the time interval’s end.
TimeInterval.EndSecond Specifies the second part of the time interval’s end.
See Also