)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to customize the legends position?

Platform: WPF |
Control: SfChart |
Published Date: April 22, 2015 |
Last Revised Date: June 26, 2019

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:

Chart 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>

Output

Legend is positioned at the top and outside of the chart in WPF

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>

Output

 

Chart legend placed at the desired position in WPF

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

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon