Back to Devexpress

DateTimeScaleOptions.WorkTimeOnly Property

corelibraries-devexpress-dot-xtracharts-dot-datetimescaleoptions-5a273fa3.md

latest3.9 KB
Original Source

DateTimeScaleOptions.WorkTimeOnly Property

Gets or sets a value indicating whether to show only the working time on a date-time axis.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
[XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)]
public bool WorkTimeOnly { get; set; }
vb
<XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)>
Public Property WorkTimeOnly As Boolean

Property Value

TypeDescription
Boolean

true if work time only should be shown on the date-time axis; otherwise false.

|

Property Paths

You can access this nested property as listed below:

Object TypePath to WorkTimeOnly
AxisBase

.DateTimeScaleOptions .WorkTimeOnly

|

Example

The following code demonstrates how to configure work time rules.

csharp
XYDiagram chartDiagram = (XYDiagram)financialChart.Diagram;
DateTimeScaleOptions xAxisScaleOptions = chartDiagram.AxisX.DateTimeScaleOptions;

// This property turns on axis values filtering by rules.
xAxisScaleOptions.WorkTimeOnly = true;

// Create a new instance of the worktime rule which will be used to specify
// the worktime displayed on the X-axis.
WorkTimeRule weekdayRule = new WorkTimeRule();
xAxisScaleOptions.WorkTimeRules.Add(weekdayRule);
// Specify one or more work intervals of this rule.
weekdayRule.WorkIntervals.Add(new TimeInterval(09, 00, 00, 19, 00, 00));
// Add weekdays on which this rule should be applied.
weekdayRule.Weekdays = Weekday.Monday | Weekday.Tuesday | Weekday.Wednesday 
        | Weekday.Thursday | Weekday.Friday;

WorkTimeRule dateRule = new WorkTimeRule();
xAxisScaleOptions.WorkTimeRules.Add(dateRule);
dateRule.WorkIntervals.Add(new TimeInterval(12, 00, 00, 16, 00, 00));
// Besides Weekdays, you can specify the Date 
// on which this rule should be applied.
dateRule.Date = new DateTime(2017, 1, 1);
vb
Dim chartDiagram As XYDiagram = DirectCast(financialChart.Diagram, XYDiagram)
Dim xAxisScaleOptions As DateTimeScaleOptions = chartDiagram.AxisX.DateTimeScaleOptions

' This property turns on axis values filtering by rules.
xAxisScaleOptions.WorkTimeOnly = True

' Create a new instance of the worktime rule which will be used to specify 
' the worktime displayed on the X-axis.
Dim weekdayRule As New WorkTimeRule()
xAxisScaleOptions.WorkTimeRules.Add(weekdayRule)
' Specify one or more work intervals of this rule.
weekdayRule.WorkIntervals.Add(New TimeInterval(09, 00, 00, 19, 00, 00))
' Add weekdays on which this rule should be applied.
weekdayRule.Weekdays = Weekday.Monday Or Weekday.Tuesday Or Weekday.Wednesday _
        Or Weekday.Thursday Or Weekday.Friday

Dim dateRule As New WorkTimeRule()
xAxisScaleOptions.WorkTimeRules.Add(dateRule)
dateRule.WorkIntervals.Add(New TimeInterval(12, 00, 00, 16, 00, 00))
' Besides Weekdays, you can specify the Date 
' on which this rule should be applied.
dateRule.Date = New DateTime(2017, 1, 1)

See Also

Work Time and Workday Configuration

DateTimeScaleOptions Class

DateTimeScaleOptions Members

DevExpress.XtraCharts Namespace