Articles in this section
Category / Section

How to customize the legends position of WPF Chart (SfChart)?

1 min read

Description:

Legends are not restricted to position on the top of chart. It needs to be placed in or around the plot area based on the series or data. This article describes how to customize the position of the legends.

Solution:

WPF Chart (SfChart) provides the following properties to align or position the legends in chart.

The DockPosition property is used to position the legends either at the bottom, left, right or top of the chart area, and the Floating property is used to position the legends anywhere over the plot area.

The OffsetX and OffsetY properties are used to give horizontal and vertical offsets for legends. These properties work only when the DockPosition is set to Floating.

The LegendPosition property is used to place the legends Inside or Outside of the plot area.

Example 1

XAML

<chart:ChartLegend x:Name="Legend1" 
                                 Header="MultipleSeries"   
                                 TextElement.FontSize="20"                        
                                 DockPosition="Top"   
                                 LegendPosition="Outside" 
                                 CheckBoxVisibility="Visible">                        
</chart:ChartLegend>

 

WPF chart displays Legend Position to Outside and DockPosition to top

Figure 1: Legends positioned with the DockPosition to Top and LegendPosition to Outside.

Example 2

XAML

<chart:ChartLegend x:Name="Legend1" 
                                 Header="MultipleSeries"  
                                 TextElement.FontSize="16"                                    
                                 OffsetX="470"
                                 OffsetY="400"
                                 DockPosition="Floating"   
                                 LegendPosition="Inside" 
                                 CheckBoxVisibility="Visible">                        
</chart:ChartLegend>

 

 

WPF chart displays Legend Position to Inside and DockPosition to Float

Figure 2: Legends with DockPosition to Floating and LegendPosition to Inside.

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied