corelibraries-devexpress-dot-xtracharts-dot-range-43324b83.md
Gets or sets the maximum value to display on an Axis. This may not be the same as the maximum value of the series associated with this axis.
Namespace : DevExpress.XtraCharts
Assembly : DevExpress.XtraCharts.v25.2.dll
NuGet Package : DevExpress.Charts
public object MaxValue { get; set; }
Public Property MaxValue As Object
| Type | Description |
|---|---|
| Object |
A Object that specifies the maximum value to display on an axis.
|
Use the MaxValue property to specify or obtain the maximum value to display on an axis.
Note that the MaxValue and Range.Auto properties are interdependent: changing one property will reset the other.
Note
Dealing with Qualitative or DateTime scale types, it may be required to determine the maximum value more precisely than allowed by these scale types. For example, for an axis whose DateTimeScaleOptions.MeasureUnit property is set to Year , it may be required to restrict its range by Month. To do this, you can use the Range.MaxValueInternal property, which stores the internal, numeric representation of Qualitative and DateTime values.
For more information, refer to Visual Ranges and Whole Ranges.
The following examples show how to set limits for the x-axis whole and visual ranges:
Use the AxisBase.WholeRange or AxisBase.VisualRange properties to access the whole or visual range settings. Then, use the Range.MinValue and Range.MaxValue properties to specify the minimum and maximum range values.
An individual axis is available via the XYDiagram.AxisX or XYDiagram.AxisY property.
You can also call the Range.SetMinMaxValues(Object, Object) method to define range limits.
XYDiagram diagram = chartControl1.Diagram as XYDiagram;
// Set limits for an x-axis's whole range.
diagram.AxisX.WholeRange.MinValue = 500;
diagram.AxisX.WholeRange.MaxValue = 2000;
// Alternatively, you can use the SetMinMaxValues method to specify range limits.
diagram.AxisX.WholeRange.SetMinMaxValues(500, 2000);
// Set limits for an x-axis's visual range.
diagram.AxisX.VisualRange.MinValue = 1000;
diagram.AxisX.VisualRange.MaxValue = 1500;
// Alternatively, you can use the SetMinMaxValues method to specify range limits.
diagram.AxisX.VisualRange.SetMinMaxValues(1000, 1500);
Dim diagram As XYDiagram = TryCast(chartControl1.Diagram, XYDiagram)
' Set the lower limit for an x-axis's whole range.
diagram.AxisX.WholeRange.MinValue = 500
' Set the upper limit for an x-axis's whole range.
diagram.AxisX.WholeRange.MaxValue = 2000
' Alternatively, you can use the SetMinMaxValues method to specify range limits.
diagram.AxisX.WholeRange.SetMinMaxValues(500, 2000)
' Set the lower limit for an x-axis's visual range.
diagram.AxisX.VisualRange.MinValue = 1000
' Set the upper limit for an x-axis's visual range.
diagram.AxisX.VisualRange.MaxValue = 1500
' Alternatively, you can use the SetMinMaxValues method to specify range limits.
diagram.AxisX.VisualRange.SetMinMaxValues(1000, 1500)
XYDiagram diagram = chartControl1.Diagram as XYDiagram;
// Set limits for an x-axis's whole range.
diagram.AxisX.WholeRange.MinValue = new DateTime(2017, 01, 01);
diagram.AxisX.WholeRange.MaxValue = new DateTime(2019, 12, 31);
// Alternatively, you can use the SetMinMaxValues method to specify range limits.
diagram.AxisX.WholeRange.SetMinMaxValues(new DateTime(2017, 01, 01), new DateTime(2019, 12, 31));
// Set limits for an x-axis's visual range.
diagram.AxisX.VisualRange.MinValue = new DateTime(2018, 01, 01);
diagram.AxisX.VisualRange.MaxValue = new DateTime(2019, 01, 01);
// Alternatively, you can use the SetMinMaxValues method to specify range limits.
diagram.AxisX.VisualRange.SetMinMaxValues(new DateTime(2018, 01, 01), new DateTime(2019, 01, 01));
Dim diagram As XYDiagram = TryCast(chartControl1.Diagram, XYDiagram)
' Set limits for an x-axis's whole range.
diagram.AxisX.WholeRange.MinValue = New DateTime(2017, 01, 01)
diagram.AxisX.WholeRange.MaxValue = New DateTime(2019, 12, 31)
' Alternatively, you can use the SetMinMaxValues method to specify range limits.
diagram.AxisX.WholeRange.SetMinMaxValues(New DateTime(2017, 01, 01), New DateTime(2019, 12, 31))
' Set limits for an x-axis's visual range.
diagram.AxisX.VisualRange.MinValue = New DateTime(2018, 01, 01)
diagram.AxisX.VisualRange.MaxValue = New DateTime(2019, 01, 01)
' Alternatively, you can use the SetMinMaxValues method to specify range limits.
diagram.AxisX.VisualRange.SetMinMaxValues(New DateTime(2018, 01, 01), New DateTime(2019, 01, 01))
XYDiagram diagram = chartControl1.Diagram as XYDiagram;
// Set limits for an x-axis's whole range.
diagram.AxisX.WholeRange.MinValue = new TimeSpan(0,0,0);
diagram.AxisX.WholeRange.MaxValue = new TimeSpan(1, 0, 0, 0);
// Alternatively, you can use the SetMinMaxValues method to specify range limits.
diagram.AxisX.WholeRange.SetMinMaxValues(new TimeSpan(0, 0, 0), new TimeSpan(1, 0, 0, 0));
// Set limits for an x-axis's visual range.
diagram.AxisX.VisualRange.MinValue = new TimeSpan(6, 0, 0);
diagram.AxisX.VisualRange.MaxValue = new TimeSpan(12, 0, 0);
// Alternatively, you can use the SetMinMaxValues method to specify range limits.
diagram.AxisX.VisualRange.SetMinMaxValues(new TimeSpan(6, 0, 0), new TimeSpan(12, 0, 0));
Dim diagram As XYDiagram = TryCast(chartControl1.Diagram, XYDiagram)
' Set limits for an x-axis's whole range.
diagram.AxisX.WholeRange.MinValue = New TimeSpan(0, 0, 0)
diagram.AxisX.WholeRange.MaxValue = New TimeSpan(1, 0, 0, 0)
' Alternatively, you can use the SetMinMaxValues method to specify range limits.
diagram.AxisX.WholeRange.SetMinMaxValues(New TimeSpan(0, 0, 0), New TimeSpan(1, 0, 0, 0))
' Set limits for an x-axis's visual range.
diagram.AxisX.VisualRange.MinValue = New TimeSpan(6, 0, 0)
diagram.AxisX.VisualRange.MaxValue = New TimeSpan(12, 0, 0)
' Alternatively, you can use the SetMinMaxValues method to specify range limits.
diagram.AxisX.VisualRange.SetMinMaxValues(New TimeSpan(6, 0, 0), New TimeSpan(12, 0, 0))
XYDiagram diagram = chartControl1.Diagram as XYDiagram;
// Use the actual string categories from the data source.
// Set limits for an x-axis's whole range.
diagram.AxisX.WholeRange.MinValue = "Camera";
diagram.AxisX.WholeRange.MaxValue = "Flash";
// Alternatively, you can use the SetMinMaxValues method to specify range limits.
diagram.AxisX.WholeRange.SetMinMaxValues("Camera", "Flash");
// Set limits for an x-axis's visual range.
diagram.AxisX.VisualRange.MinValue = "Camcorder";
diagram.AxisX.VisualRange.MaxValue = "Binoculars";
// Alternatively, you can use the SetMinMaxValues method to specify range limits.
diagram.AxisX.VisualRange.SetMinMaxValues("Camcorder", "Binoculars");
Dim diagram As XYDiagram = TryCast(chartControl1.Diagram, XYDiagram)
' Use the actual string categories from the data source.
' Set limits for an x-axis's whole range
diagram.AxisX.WholeRange.MinValue = "Camera"
diagram.AxisX.WholeRange.MaxValue = "Flash"
' Alternatively, you can use the SetMinMaxValues method to specify range limits.
diagram.AxisX.WholeRange.SetMinMaxValues("Camera", "Flash")
' Set limits for an x-axis's visual range
diagram.AxisX.VisualRange.MinValue = "Camcorder"
diagram.AxisX.VisualRange.MaxValue = "Binoculars"
' Alternatively, you can use the SetMinMaxValues method to specify range limits.
diagram.AxisX.VisualRange.SetMinMaxValues("Camcorder", "Binoculars")
The following code snippets (auto-collected from DevExpress Examples) contain references to the MaxValue 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#L25
WholeRange range = ((XYDiagram)(sender as ChartControl).Diagram).AxisY.WholeRange;
double delta = ((double)range.MaxValue - (double)range.MinValue) / 8;
winforms-charts-plot-xy-series-with-histogram/CS/Form1.cs#L41
diagram.AxisX.WholeRange.MinValue = MinValue;
diagram.AxisX.WholeRange.MaxValue = MaxValue;
diagram.AxisX.WholeRange.SideMarginsValue = 0;
winforms-chart-make-points-in-a-chartcontrol-adjustable-interactively/VB/Form1.vb#L26
Dim range As WholeRange = CType(TryCast(sender, ChartControl).Diagram, XYDiagram).AxisY.WholeRange
Dim delta As Double =(CDbl(range.MaxValue) - CDbl(range.MinValue)) / 8
If selectedPoint.Values(0) >= CDbl(range.MaxValue) - delta Then range.MaxValue = selectedPoint.Values(0) + delta
winforms-charts-plot-xy-series-with-histogram/VB/Form1.vb#L68
diagram.AxisX.WholeRange.MinValue = MinValue
diagram.AxisX.WholeRange.MaxValue = MaxValue
diagram.AxisX.WholeRange.SideMarginsValue = 0
See Also