Skip to main content

How to: Adjust Series Labels

This example demonstrates how you can access the options of series labels, in order to automatically resolve overlapping labels, as well as adjust their position and appearance.

<Window x:Class="AdjustSeriesPointLabels.MainWindow"
        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="MainWindow" Height="350" Width="525" >
    <Grid>
        <dxc:ChartControl>
            <dxc:ChartControl.Diagram>
                <dxc:XYDiagram2D>
                    <dxc:XYDiagram2D.Series>
                        <dxc:PointSeries2D LabelsVisibility="True" >
                            <dxc:PointSeries2D.Points>
                                <dxc:SeriesPoint Argument="A" Value="21.4231" />
                                <dxc:SeriesPoint Argument="B" Value="22.5364" />
                                <dxc:SeriesPoint Argument="C" Value="21.4532" />
                                <dxc:SeriesPoint Argument="D" Value="21.8675" />
                                <dxc:SeriesPoint Argument="E" Value="22.6478" />
                                <dxc:SeriesPoint Argument="F" Value="21.4358" />
                                <dxc:SeriesPoint Argument="G" Value="22.3695" />
                                <dxc:SeriesPoint Argument="H" Value="21.7685" />
                                <dxc:SeriesPoint Argument="I" Value="22.4231" />
                                <dxc:SeriesPoint Argument="J" Value="22.5364" />
                                <dxc:SeriesPoint Argument="K" Value="21.4532" />
                                <dxc:SeriesPoint Argument="L" Value="21.8675" />
                            </dxc:PointSeries2D.Points>
                            <!--Adjust the series point labels.-->
                            <dxc:PointSeries2D.Label>
                                <dxc:SeriesLabel ResolveOverlappingMode="JustifyAllAroundPoint"
                                                 Indent="10"
                                                 ConnectorVisible="False"
                                                 Opacity="0.7">
                                </dxc:SeriesLabel>
                            </dxc:PointSeries2D.Label>
                        </dxc:PointSeries2D>
                    </dxc:XYDiagram2D.Series>
                    <!--Adjust the Y-axis' range, to avoid empty space.-->
                    <dxc:XYDiagram2D.AxisY>
                        <dxc:AxisY2D>
                            <dxc:AxisY2D.Range>
                                <dxc:AxisRange MinValue="20" MaxValue="24"/>
                            </dxc:AxisY2D.Range>
                        </dxc:AxisY2D>
                    </dxc:XYDiagram2D.AxisY>
                </dxc:XYDiagram2D>
            </dxc:ChartControl.Diagram>
            <dxc:ChartControl.Titles>
                <dxc:Title Content="Resolve Overlapping for Point Labels" />
            </dxc:ChartControl.Titles>
        </dxc:ChartControl>
    </Grid>
</Window>