Back to Devexpress

AxisLabel2D.Alignment Property

corelibraries-devexpress-dot-xtracharts-dot-axislabel2d-03eb67f0.md

latest5.1 KB
Original Source

AxisLabel2D.Alignment Property

Gets or sets the axis label alignment.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

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

Property Value

TypeDescription
AxisLabelAlignment

The value that specifies the label alignment.

|

Available values:

NameDescription
Auto

The label alignment depends on the Axis2D.Alignment property value.

| | Center |

Axis labels are centered with major tickmarks.

| | Far |

Axis labels are displayed at the major tickmark right or top side in depending on axis type and orientation.

| | Near |

Axis labels are displayed at the major tickmark left or bottom side in depending on axis type and orientation.

|

Remarks

The following label alignments are available:

AlignmentExample
AxisLabelAlignment.Center
AxisLabelAlignment.Far
AxisLabelAlignment.Near
AxisLabelAlignment.AutoThe axis label alignment depends on the Axis2D.LabelPosition property value.

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.

See Also

AxisLabel2D Class

AxisLabel2D Members

DevExpress.XtraCharts Namespace