Skip to main content
A newer version of this page is available. .

AxisLabel Class

Contains settings for axis labels.

Namespace: DevExpress.Xpf.Charts

Assembly: DevExpress.Xpf.Charts.v19.1.dll

Declaration

public class AxisLabel :
    ChartTextElement,
    IAxisLabel,
    ISupportFlowDirection,
    IWeakEventListener,
    IPatternHolder

The following members return AxisLabel objects:

Remarks

The AxisLabel class provides different settings that define the position of axis labels (AxisLabel.Staggered) and text format (AxisLabel.BeginText, AxisLabel.EndText).

An instance of the AxisLabel class is available via the AxisBase.Label property.

Example

The following example demonstrates how to change the appearance of axis labels, for example, to rotate them by a specific angle. To accomplish this, it is necessary to create a DataTemplate that specifies the appearance of axis labels, and add it to a window’s resources collection. Then, this template can be applied to an axis label via its ChartTextElement.ElementTemplate property.

<Window x:Class="RotatedAxisXLabels.Window1" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts" 
        Title="Rotated AxisX Labels" Height="300" Width="400">

    <Window.Resources>
        <DataTemplate x:Key="AxisXLabelTemplate">
            <ContentPresenter Content="{Binding Path=Content}">
                <ContentPresenter.LayoutTransform>
                    <RotateTransform Angle="-90" />
                </ContentPresenter.LayoutTransform>
            </ContentPresenter>
        </DataTemplate>
    </Window.Resources>

    <Grid>
        <dxc:ChartControl Name="chartControl1">
            <dxc:ChartControl.Diagram>
                <dxc:XYDiagram2D>
                    <dxc:XYDiagram2D.AxisX>
                        <dxc:AxisX2D>
                            <dxc:AxisX2D.Label>
                                <dxc:AxisLabel ElementTemplate="{StaticResource AxisXLabelTemplate}" 
                                               Padding="0,0,5,4" />
                            </dxc:AxisX2D.Label>
                        </dxc:AxisX2D>
                    </dxc:XYDiagram2D.AxisX>
                    <dxc:XYDiagram2D.Series>
                        <dxc:BarSideBySideSeries2D>
                            <dxc:BarSideBySideSeries2D.Points>
                                <dxc:SeriesPoint Argument="First Argument" Value="1" />
                                <dxc:SeriesPoint Argument="Second Argument" Value="2" />
                                <dxc:SeriesPoint Argument="Third Argument" Value="3" />
                                <dxc:SeriesPoint Argument="Fourth Argument" Value="4" />
                                <dxc:SeriesPoint Argument="Fifth Argument" Value="5" />
                            </dxc:BarSideBySideSeries2D.Points>
                        </dxc:BarSideBySideSeries2D>
                    </dxc:XYDiagram2D.Series>
                </dxc:XYDiagram2D>
            </dxc:ChartControl.Diagram>
        </dxc:ChartControl>
    </Grid>
</Window>

The following code snippets (auto-collected from DevExpress Examples) contain references to the AxisLabel class.

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