Articles in this section
Category / Section

How to add multiple legend items in scroll viewer of WPF Chart (SfChart)?

1 min read

Description:

This article describes how to add multiple legend items inside the scrollbar in WPF Chart (SfChart). Legend items represent the label values of chart series. When a large number of series are added to the chart, some legend items may be hidden from view. To address this, SfChart allows the legend to be placed inside a scrollbar, enabling users to scroll and view all items.


Solution:

If you want to add multiple legend items inside any container such as scroll viewer, you need to define the control template for the legends in WPF Chart (SfChart).


[XAML]

<!—Adding ScrollViewer for Legend items-->
<chart:SfChart x:Name="sfchart" Margin="10" >
    <chart:SfChart.Legend>
        <chart:ChartLegend  DockPosition="Top">
            <chart:ChartLegend.Template>
                <ControlTemplate>
                    <ScrollViewer Margin="30" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
                        <ItemsPresenter>
                        </ItemsPresenter>
                    </ScrollViewer>
                </ControlTemplate>
            </chart:ChartLegend.Template>
        </chart:ChartLegend>
    </chart:SfChart.Legend>
</chart:SfChart>

 Output


WPF Chart displays Multiple Items in ScrollViewer



Conclusion

I hope you enjoyed learning how to add multiple legend items in scroll viewer of WPF Chart (SfChart).

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