Back to Devexpress

ScaleOptionsBase.ScaleMode Property

corelibraries-devexpress-dot-xtracharts-dot-scaleoptionsbase.md

latest13.4 KB
Original Source

ScaleOptionsBase.ScaleMode Property

Gets or sets the scale mode for an axis.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
public ScaleMode ScaleMode { get; set; }
vb
Public Property ScaleMode As ScaleMode

Property Value

TypeDescription
ScaleMode

A scale mode.

|

Available values:

NameDescription
Automatic

Identifies the automatic scale mode, meaning that data is automatically aggregated according to the chosen ScaleGridOptionsBase.AggregateFunction.

| | Manual |

Identifies the manual scale mode, meaning that the GridAlignment (DateTimeScaleOptions.GridAlignment, NumericScaleOptions.GridAlignment or TimeSpanScaleOptions.GridAlignment) and MeasureUnit (DateTimeScaleOptions.MeasureUnit, NumericScaleOptions.MeasureUnit or TimeSpanScaleOptions.MeasureUnit) properties are in effect, and they should be manually defined. Also, you can use the ScaleGridOptionsBase.AggregateFunction property to choose the aggregate function.

| | Continuous |

Identifies the continuous scale mode, meaning data aggregation is disabled and you can only change the grid alignment using the GridAlignment (DateTimeScaleOptions.GridAlignment, NumericScaleOptions.GridAlignment or TimeSpanScaleOptions.GridAlignment) property.

| | Interval |

Identifies the interval scale mode, which means that the axis scale is divided into intervals. Note that the Chart Control does not apply the resampling mechanism to points in this scale mode.

|

Remarks

Use the ScaleMode property to define which scale mode should be used for an axis: manual, automatic, interval or continuous.

Note that when automatic mode is defined, the DateTimeScaleOptions.GridAlignment and DateTimeScaleOptions.MeasureUnit properties aren’t available. You can change these properties in this mode using the ChartControl.AxisScaleChanged(WebChartControl.AxisScaleChanged or ChartControlSettings.AxisScaleChanged) event handler.

The following images demonstrate this property in action for the date-time data.

|

The property value

|

The resulting image

| | --- | --- | |

ScaleMode = Manual;

MeasureUnit = Quarter;

|

| |

ScaleMode = Automatic

|

| |

ScaleMode = Continuous

|

| |

ScaleMode = Interval

|

|

Example

This example shows how to use DateTimeScaleOptions to reduce the number of visible series points.

The following code configures the axis scale settings to resemble to the chart appearance above:

csharp
DateTimeScaleOptions dateTimeScaleOptions = ((XYDiagram)chartControl.Diagram).AxisX.DateTimeScaleOptions;

dateTimeScaleOptions.WorkdaysOnly = true;
dateTimeScaleOptions.ScaleMode = ScaleMode.Manual;
dateTimeScaleOptions.AggregateFunction = AggregateFunction.Average;
dateTimeScaleOptions.MeasureUnit = DateTimeMeasureUnit.Month;
dateTimeScaleOptions.GridAlignment = DateTimeGridAlignment.Quarter;
dateTimeScaleOptions.GridSpacing = 1;
vb
Dim dateTimeScaleOptions As DateTimeScaleOptions = CType(chartControl.Diagram,XYDiagram).AxisX.DateTimeScaleOptions

dateTimeScaleOptions.WorkdaysOnly = true
dateTimeScaleOptions.ScaleMode = ScaleMode.Manual
dateTimeScaleOptions.AggregateFunction = AggregateFunction.Average
dateTimeScaleOptions.MeasureUnit = DateTimeMeasureUnit.Month
dateTimeScaleOptions.GridAlignment = DateTimeGridAlignment.Quarter
dateTimeScaleOptions.GridSpacing = 1

The following table lists the API members the code above uses:

MemberDescription
AxisBase.DateTimeScaleOptionsStores the options that define the behavior of a scale when its type is date-time.
ScaleOptionsBase.ScaleModeGets or sets the scale mode for an axis.
ScaleModeLists the values that specify the scale mode for an axis.
DateTimeScaleOptions.MeasureUnitGets or sets the detail level for date-time values.
DateTimeMeasureUnitLists the values that specify the detail level for date-time values.
ScaleGridOptionsBase.GridOffsetGets or sets the offset of grid lines and major tickmarks.
ScaleGridOptionsBase.AggregateFunctionGets or sets the value indicating the aggregate function that should be used to relieve data.
AggregateFunctionLists the values that specify the aggregate function used for an axis.
DateTimeScaleOptions.GridAlignmentGets or sets the date-time measure unit to which the beginning of an axis’ gridlines and labels should be aligned.
DateTimeGridAlignmentLists the values that specify the date-time measurement unit, to which the beginning of a diagram’s gridlines and labels should be aligned.
ScaleGridOptionsBase.GridSpacingGets or sets the interval between grid lines and major tickmarks.

The following code snippets (auto-collected from DevExpress Examples) contain references to the ScaleMode 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-charts-use-automatic-date-time-scale-modes-of-an-axis/CS/DateTimeAggregation/Form1.cs#L122

csharp
switch (AxisX.DateTimeScaleOptions.ScaleMode) {
    case ScaleMode.Automatic: {

asp-net-web-forms-web-chart-control-create-drill-down-chart/CS/DrillDownChart/WebForm1.aspx.cs#L28

csharp
if (diagram != null && WebChartControl1.Series.Count > 0) {
    diagram.AxisX.DateTimeScaleOptions.ScaleMode = ScaleMode.Automatic;
    diagram.AxisX.DateTimeScaleOptions.AggregateFunction = AggregateFunction.Sum;

winforms-charts-create-real-time-chart/CS/RealTimeChartUpdates/Form1.cs#L29

csharp
XYDiagram diagram = (XYDiagram)chartControl1.Diagram;
diagram.AxisX.DateTimeScaleOptions.ScaleMode = ScaleMode.Continuous;
diagram.AxisX.Label.ResolveOverlappingOptions.AllowRotate = false;

winforms-charts-create-real-time-chart-and-collect-data-in-separate-thread/CS/RealTimeChartUpdates/Form1.cs#L38

csharp
XYDiagram diagram = (XYDiagram)chartControl1.Diagram;
diagram.AxisX.DateTimeScaleOptions.ScaleMode = ScaleMode.Continuous;
diagram.AxisX.Label.ResolveOverlappingOptions.AllowRotate = false;

winforms-charts-plot-xy-series-with-histogram/CS/Form1.cs#L38

csharp
XYDiagram diagram = (XYDiagram)chartControl1.Diagram;
diagram.AxisX.NumericScaleOptions.ScaleMode = ScaleMode.Interval;
diagram.AxisX.Visibility = DevExpress.Utils.DefaultBoolean.True;

winforms-charts-use-automatic-date-time-scale-modes-of-an-axis/VB/DateTimeAggregation/Form1.vb#L109

vb
cbAggregateFunction.Enabled = True
Select Case AxisX.DateTimeScaleOptions.ScaleMode
    Case ScaleMode.Automatic

asp-net-web-forms-web-chart-control-create-drill-down-chart/VB/DrillDownChart/WebForm1.aspx.vb#L29

vb
If diagram IsNot Nothing AndAlso WebChartControl1.Series.Count > 0 Then
    diagram.AxisX.DateTimeScaleOptions.ScaleMode = ScaleMode.Automatic
    diagram.AxisX.DateTimeScaleOptions.AggregateFunction = AggregateFunction.Sum

winforms-charts-create-real-time-chart/VB/RealTimeChartUpdates/Form1.vb#L33

vb
Dim diagram As XYDiagram = CType(chartControl1.Diagram, XYDiagram)
diagram.AxisX.DateTimeScaleOptions.ScaleMode = ScaleMode.Continuous
diagram.AxisX.Label.ResolveOverlappingOptions.AllowRotate = False

winforms-charts-create-real-time-chart-and-collect-data-in-separate-thread/VB/RealTimeChartUpdates/Form1.vb#L48

vb
Dim diagram As XYDiagram = CType(chartControl1.Diagram, XYDiagram)
diagram.AxisX.DateTimeScaleOptions.ScaleMode = ScaleMode.Continuous
diagram.AxisX.Label.ResolveOverlappingOptions.AllowRotate = False

winforms-charts-plot-xy-series-with-histogram/VB/Form1.vb#L65

vb
Dim diagram As XYDiagram = CType(chartControl1.Diagram, XYDiagram)
diagram.AxisX.NumericScaleOptions.ScaleMode = ScaleMode.Interval
diagram.AxisX.Visibility = DevExpress.Utils.DefaultBoolean.True

See Also

ScaleOptionsBase Class

ScaleOptionsBase Members

DevExpress.XtraCharts Namespace