Back to Devexpress

Axis2D.VisualRange Property

wpf-devexpress-dot-xpf-dot-charts-dot-axis2d-8f4df706.md

latest4.6 KB
Original Source

Axis2D.VisualRange Property

Gets or sets the settings that specify the visible range of the axis coordinates.

Namespace : DevExpress.Xpf.Charts

Assembly : DevExpress.Xpf.Charts.v25.2.dll

NuGet Package : DevExpress.Wpf.Charts

Declaration

csharp
public Range VisualRange { get; set; }
vb
Public Property VisualRange As Range

Property Value

TypeDescription
Range

A Range object which contains the common visual range settings of the axis coordinates.

|

Remarks

The VisualRange property is used in descendants of the AxisBase class. The primary settings exposed via the properties of the Range class allow you to specify, for example, the minimum and maximum axis values (see the Range.MinValue and Range.MaxValue properties).

Examples

The following markup shows how to specify visual and whole ranges:

xaml
<!--...-->
<dxc:XYDiagram2D.AxisX>
    <dxc:AxisX2D>
        <dxc:AxisX2D.WholeRange>
            <dxc:Range MinValue="05/24/2016" 
                       MaxValue="08/25/2016"/>
        </dxc:AxisX2D.WholeRange>
        <dxc:AxisX2D.VisualRange>
            <dxc:Range MinValue="06/18/2016" 
                       MaxValue="07/03/2016"/>
        </dxc:AxisX2D.VisualRange>
    </dxc:AxisX2D>
</dxc:XYDiagram2D.AxisX>
<!--...-->

The markup above uses the following classes and properties:

Class or PropertyDescription
Axis.WholeRangeGets or sets the axis whole range’s settings.
Axis2D.VisualRangeGets or sets the axis visual range’s settings.
RangeThe axis range.
Range.MinValueThe range’s minimum limit.
Range.MaxValueThe range’s maximum limit.

You can call the Range.SetMinMaxValues method to limit a range at runtime. The following code customizes an x-axis’s visual range:

csharp
using DevExpress.Xpf.Charts;

private void Window_Loaded(object sender, RoutedEventArgs e) {
    Range visualRange = ((XYDiagram2D)chartControl1.Diagram).ActualAxisX.ActualVisualRange;
    visualRange.SetMinMaxValues(minValue: new DateTime(2019, 4, 1), maxValue: new DateTime(2019, 10, 1));
}
vb
Imports DevExpress.Xpf.Charts

Private Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
    Dim visualRange As Range = CType(chartControl1.Diagram, XYDiagram2D).ActualAxisX.ActualVisualRange
    visualRange.SetMinMaxValues(minValue:=New DateTime(2019, 4, 1), maxValue:=New DateTime(2019, 10, 1))
End Sub

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the VisualRange 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.

wpf-bind-a-range-control-to-a-chart-control/CS/GoldPrices/MainWindow.xaml#L45

xml
</dxc:AxisX2D.DateTimeScaleOptions>
<dxc:AxisX2D.VisualRange>
    <dxc:Range MinValue="{Binding ElementName=rangeControl, Path=SelectionRangeStart, Mode=TwoWay}"

See Also

Whole and Visual Ranges

Axis2D Class

Axis2D Members

DevExpress.Xpf.Charts Namespace