Back to Devexpress

Axis2D.Alignment Property

corelibraries-devexpress-dot-xtracharts-dot-axis2d-7283f1a9.md

latest8.0 KB
Original Source

Axis2D.Alignment Property

Specifies the position of an axis relative to another primary axis.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
[XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)]
public AxisAlignment Alignment { get; set; }
vb
<XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)>
Public Property Alignment As AxisAlignment

Property Value

TypeDescription
AxisAlignment

An AxisAlignment enumeration value which specifies the relative position of the current axis.

|

Available values:

NameDescription
Near

An axis is displayed at the left or bottom side of the diagram, depending on its type and orientation.

| | Far |

An axis is displayed at the right or top side of the diagram, depending on its type and orientation.

| | Zero |

An axis intercepts another primary axis at the zero level.

This alignment type is applicable to primary axes only.

In this mode, an axis title and labels are shown within the pane.

For an axis of (Y) values, the zero level is its zero line.

For an axis of (X) arguments, the zero level depends upon a series’ SeriesBase.ArgumentScaleType property value:

| | Center |

The axis is positioned in the center of chart plot area.

This alignment type is applicable to primary axes only.

In this mode, an axis title and labels are shown within the pane.

|

Remarks

You can use the following alignments to specify the Alignment property:

AlignmentThe example image
Center
Far
Near
Zero

Example

This example configures the axis label and axis title appearance.

The following code configures options of a y-axis to resemble to its appearance in the image above:

csharp
XYDiagram diagram = chartControl.Diagram as XYDiagram;
diagram.AxisY.Title.Position = AxisTitlePosition.Outside;
diagram.AxisY.Title.Text = "Total Harmonic Distortion";
diagram.AxisY.Title.Alignment = System.Drawing.StringAlignment.Center;
diagram.AxisY.Label.Alignment = AxisLabelAlignment.Far;
diagram.AxisY.LabelPosition = AxisLabelPosition.Inside;
diagram.AxisY.Label.TextPattern = "{V:0.##}%";
diagram.AxisY.Alignment = AxisAlignment.Near;
vb
Dim diagram As XYDiagram = CType(chartControl.Diagram,XYDiagram)
diagram.AxisY.Title.Position = AxisTitlePosition.Outside
diagram.AxisY.Title.Text = "Total Harmonic Distortion"
diagram.AxisY.Title.Alignment = System.Drawing.StringAlignment.Center
diagram.AxisY.Label.Alignment = AxisLabelAlignment.Far
diagram.AxisY.LabelPosition = AxisLabelPosition.Inside
diagram.AxisY.Label.TextPattern = "{V:0.##}%"
diagram.AxisY.Alignment = AxisAlignment.Near

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

MemberDescription
AxisTitle.PositionGets or sets the axis title position.
Title.TextGets or sets the title’s text.
AxisTitle.AlignmentGets or sets the alignment of the axis title.
AxisLabel2D.AlignmentGets or sets the axis label alignment.
Axis2D.LabelPositionGets or sets the axis label position.
AxisLabel.TextPatternGets or sets a string that formats text for the auto-generated x- or y-axis labels.
Axis2D.AlignmentSpecifies the position of an axis relative to another primary axis.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Alignment 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-change-series-line-color-when-value-is-under-predefined-level/CS/Form1.cs#L33

csharp
series.Label.TextPattern = "{V:N2}";
    (chartControl1.Diagram as XYDiagram).AxisX.Alignment = AxisAlignment.Zero;
}

winforms-charts-change-series-line-color-when-value-is-under-predefined-level/VB/Form1.vb#L37

vb
series.Label.TextPattern = "{V:N2}"
    TryCast(chartControl1.Diagram, XYDiagram).AxisX.Alignment = AxisAlignment.Zero
End Sub

See Also

Axis2D Class

Axis2D Members

DevExpress.XtraCharts Namespace