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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Need to combine multiple line series to single legend item

Thread ID:

Created:

Updated:

Platform:

Replies:

151296 Feb 6,2020 06:14 AM UTC Mar 16,2021 09:12 AM UTC WPF 3
loading
Tags: SfChart
Ranjithkumar caliaperoumal
Asked On February 6, 2020 06:14 AM UTC

I want to combine multiple line series to single legend item which has same label name.

Lavanya Anaimuthu [Syncfusion]
Replied On February 7, 2020 08:55 AM UTC

Hi Ranjithkumar caliaperoumal,  
  
Greetings from Syncfusion.  
  
Query 1: How to combine multiple line series to map under one legenditem?  
You can enable one legend item by setting VisibilityOnLegend as Visible for primary series and collapsed the VisibilityOnLegend for other series and binding the first series visibility to other IsSeriesVisible property as per in the below code snippet.  
  
Code Snippet [Xaml]:  
  
<syncfusion:SfChart.Legend>  
                <syncfusion:ChartLegend CheckBoxVisibility="Visible" ToggleSeriesVisibility="True"/>  
</syncfusion:SfChart.Legend>  
  
<syncfusion:LineSeries x:Name="series1" ItemsSource="{Binding Data}" XBindingPath="XValue" YBindingPath="YValue" Label="Series1" VisibilityOnLegend="Visible" />  
                <syncfusion:LineSeries ItemsSource="{Binding Data}" XBindingPath="XValue" YBindingPath="YValue1" Label="Series2" VisibilityOnLegend="Collapsed" IsSeriesVisible="{Binding ElementName=series1, Path=IsSeriesVisible}"/>  
                <syncfusion:LineSeries ItemsSource="{Binding Data}" XBindingPath="XValue" YBindingPath="YValue2" Label="Series3" VisibilityOnLegend="Collapsed" IsSeriesVisible="{Binding ElementName=series1, Path=IsSeriesVisible}"/>  
  
And we have prepared a sample based on your requirement and download the sample from below link.  
  
  
Screenshot:  
   
Thanks, 
Lavanya A. 
 


Zeljko Lazic
Replied On March 15, 2021 07:57 PM UTC

If the line series are being created at runtime. How would you create the bindings in the viewmodel or codebehind?

Yuvaraj Palanisamy [Syncfusion]
Replied On March 16, 2021 09:12 AM UTC

Hi Zeljko Lazic, 
 
We have created the series at run time and bind the series collection to the Series property of SfChart. Please find the code example below. 
 
CodeSnippet: 
 
<syncfusion:SfChart x:Name="chart" Series="{Binding Series}" > 
 

Also, we have attached the sample for your reference. Please find the sample from the below link.
 
 

Regards,
 
Yuvaraj. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

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

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