Skip to main content

Range.MaxValue Property

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.v24.1.dll

NuGet Package: DevExpress.Charts

Declaration

[TypeConverter(typeof(RangeValueTypeConverter))]
[XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
public object MaxValue { get; set; }

Property Value

Type Description
Object

A Object that specifies the maximum value to display on an axis.

Remarks

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.

Example

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.

How to Limit the Numeric Axis Range

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);

How to Limit the Date-Time Axis Range

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));

How to Limit the Time-Span Axis Range

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));

How to Limit the Qualitative Axis Range

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");

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.

See Also