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 being positioned only at the top of a chart. They can be placed either inside or around the plot area based on the series or data presentation needs. This article describes how to customize the position of legends in a Syncfusion WPF Chart.

Solution:

WPF Chart (SfChart) provides the following properties to align or position the legends within the chart:

  • The DockPosition property is used to position the legends at the bottom, left, right, or top of the chart area. The Floating property allows you 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 are effective only when the DockPosition is set to Floating
  • The LegendPosition property is used to place the legends either Inside or Outside 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 set to Top and LegendPosition set 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:

WPF chart displays Legend Position to Inside and DockPosition to Float

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


Conclusion

I hope you enjoyed learning how to customize the legends position of WPF Chart.

You can refer to our WPF Chart feature tour page know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WPF Chart Examples to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

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