Back to Devexpress

AxisBase.WholeRange Property

corelibraries-devexpress-dot-xtracharts-dot-axisbase.md

latest9.8 KB
Original Source

AxisBase.WholeRange Property

Gets the range through which it’s possible to scroll an axis.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
[PersistenceMode(PersistenceMode.InnerProperty)]
[XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)]
public WholeRange WholeRange { get; }
vb
<XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)>
<PersistenceMode(PersistenceMode.InnerProperty)>
Public ReadOnly Property WholeRange As WholeRange

Property Value

TypeDescription
WholeRange

A WholeRange object representing the settings for the whole range of an axis.

|

Remarks

Use the WholeRange property to define the whole range in which scrolling is allowed for an axis, when scrolling is enabled (the XYDiagram2D.EnableAxisXScrolling or XYDiagram2D.EnableAxisYScrolling property is set to true ) and the automatic axis range detection is switched off (the Range.Auto property is set to false ).

Then, you can set the Range.Auto property to false , and manually define the Range.MaxValue and Range.MinValue properties to determine the axis values through which the diagram can be scrolled. You can also obtain Range.MaxValueInternal and Range.MinValueInternal properties.

In addition, you can use the Range.AutoSideMargins property to force an axis to automatically extend its range so that indents are preserved on the both ends of the axis.

For more information, refer to Visual Ranges and Whole Ranges and Zooming and Scrolling (2D XY-Charts).

Example

This example demonstrates how to use the AxisBase.VisualRange property to define the visible range of an axis, and the AxisBase.WholeRange property to define its whole range.

For more information on axis range, refer to Visual Ranges and Whole Ranges.

csharp
using DevExpress.XtraCharts;
using System;
using System.Windows.Forms;

namespace WindowsFormsApplication1 {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e) {

            // Create a chart control.
            ChartControl chartControl1 = new ChartControl();

            // Add the chart to the form.
            chartControl1.Dock = DockStyle.Fill;
            this.Controls.Add(chartControl1);

            // Create a bar series and add points to it.
            Series series1 = new Series("Series 1", ViewType.Bar);
            series1.Points.Add(new SeriesPoint("A", new double[] { 26.25 }));
            series1.Points.Add(new SeriesPoint("B", new double[] { 1.52 }));
            series1.Points.Add(new SeriesPoint("C", new double[] { 22.21 }));
            series1.Points.Add(new SeriesPoint("D", new double[] { 15.35 }));
            series1.Points.Add(new SeriesPoint("E", new double[] { 4.15 }));

            // Add the series to the chart.
            chartControl1.Series.Add(series1);

            // Cast the chart's diagram to the XYDiagram type, to access its axes.
            XYDiagram diagram = (XYDiagram)chartControl1.Diagram;

            // Enable the diagram's scrolling.
            diagram.EnableAxisXScrolling = true;
            diagram.EnableAxisYScrolling = true;

            // Define the whole range for the X-axis. 
            diagram.AxisX.WholeRange.Auto = false;
            diagram.AxisX.WholeRange.SetMinMaxValues("A", "D");

            // Disable the side margins 
            // (this has an effect only for certain view types).
            diagram.AxisX.VisualRange.AutoSideMargins = false;

            // Limit the visible range for the X-axis.
            diagram.AxisX.VisualRange.Auto = false;
            diagram.AxisX.VisualRange.SetMinMaxValues("B", "C");

            // Define the whole range for the Y-axis. 
            diagram.AxisY.WholeRange.Auto = false;
            diagram.AxisY.WholeRange.SetMinMaxValues(1, 26);
        }
    }
}
vb
Imports DevExpress.XtraCharts
Imports System
Imports System.Windows.Forms

Namespace WindowsFormsApplication1
    Partial Public Class Form1
        Inherits Form

        Public Sub New()
            InitializeComponent()
        End Sub

        Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load

            ' Create a chart control.
            Dim chartControl1 As New ChartControl()

            ' Add the chart to the form.
            chartControl1.Dock = DockStyle.Fill
            Me.Controls.Add(chartControl1)

            ' Create a bar series and add points to it.
            Dim series1 As New Series("Series 1", ViewType.Bar)
            series1.Points.Add(New SeriesPoint("A", New Double() { 26.25 }))
            series1.Points.Add(New SeriesPoint("B", New Double() { 1.52 }))
            series1.Points.Add(New SeriesPoint("C", New Double() { 22.21 }))
            series1.Points.Add(New SeriesPoint("D", New Double() { 15.35 }))
            series1.Points.Add(New SeriesPoint("E", New Double() { 4.15 }))

            ' Add the series to the chart.
            chartControl1.Series.Add(series1)

            ' Cast the chart's diagram to the XYDiagram type, to access its axes.
            Dim diagram As XYDiagram = CType(chartControl1.Diagram, XYDiagram)

            ' Enable the diagram's scrolling.
            diagram.EnableAxisXScrolling = True
            diagram.EnableAxisYScrolling = True

            ' Define the whole range for the X-axis. 
            diagram.AxisX.WholeRange.Auto = False
            diagram.AxisX.WholeRange.SetMinMaxValues("A", "D")

            ' Disable the side margins 
            ' (this has an effect only for certain view types).
            diagram.AxisX.VisualRange.AutoSideMargins = False

            ' Limit the visible range for the X-axis.
            diagram.AxisX.VisualRange.Auto = False
            diagram.AxisX.VisualRange.SetMinMaxValues("B", "C")

            ' Define the whole range for the Y-axis. 
            diagram.AxisY.WholeRange.Auto = False
            diagram.AxisY.WholeRange.SetMinMaxValues(1, 26)
        End Sub
    End Class
End Namespace

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

winforms-chart-make-points-in-a-chartcontrol-adjustable-interactively/CS/Form1.cs#L24

csharp
// Update AxisY.WholeRange if the point is too close to diagram bounds
WholeRange range = ((XYDiagram)(sender as ChartControl).Diagram).AxisY.WholeRange;
double delta = ((double)range.MaxValue - (double)range.MinValue) / 8;

winforms-chart-make-points-in-a-chartcontrol-adjustable-interactively/VB/Form1.vb#L25

vb
' Update AxisY.WholeRange if the point is too close to diagram bounds
Dim range As WholeRange = CType(TryCast(sender, ChartControl).Diagram, XYDiagram).AxisY.WholeRange
Dim delta As Double =(CDbl(range.MaxValue) - CDbl(range.MinValue)) / 8

See Also

EnableAxisXScrolling

EnableAxisYScrolling

Auto

Axis Ranges

Zoom and Scroll in 2D XY-Charts

AxisBase Class

AxisBase Members

DevExpress.XtraCharts Namespace