wpf-devexpress-dot-xpf-dot-charts-dot-axis2d-8f4df706.md
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
public Range VisualRange { get; set; }
Public Property VisualRange As Range
| Type | Description |
|---|---|
| Range |
A Range object which contains the common visual range settings of the axis coordinates.
|
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).
The following markup shows how to specify visual and whole ranges:
<!--...-->
<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 Property | Description |
|---|---|
| Axis.WholeRange | Gets or sets the axis whole range’s settings. |
Axis2D.VisualRange | Gets or sets the axis visual range’s settings. |
| Range | The axis range. |
| Range.MinValue | The range’s minimum limit. |
| Range.MaxValue | The 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:
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));
}
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
</dxc:AxisX2D.DateTimeScaleOptions>
<dxc:AxisX2D.VisualRange>
<dxc:Range MinValue="{Binding ElementName=rangeControl, Path=SelectionRangeStart, Mode=TwoWay}"
See Also