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.
Unfortunately, activation email could not send to your email. Please try again.

How to create custom legend item

Thread ID:

Created:

Updated:

Platform:

Replies:

126001 Sep 16,2016 10:06 AM Sep 19,2016 11:38 PM WPF 3
loading
Tags: SfChart
Gregory
Asked On September 16, 2016 10:06 AM

Hello,

On my Columnserie, i have customised the color. I have  2 color on this serie (blue and green column).
So i need a special legend and i haven't found any easy way to implemt a legend for theses 2 colors.

I use this code, but i don't know how to set an icon and his color to a legenditem.

private void CreateLegend()
           {
               LegendItem item = new LegendItem();
               item.CheckBoxVisibility = Visibility.Collapsed;
               item.Interior = Brushes.Green;
               item.IconHeight = 10;
               item.IconWidth = 10;
               item.IconVisibility = Visibility.Visible;
               item.Stroke = Brushes.Black;
               item.StrokeThickness = 1;
               item.Label = "Week";
               item.Series = ColSerie;
               ....
               ....
               ChartLegend legend2 = new ChartLegend();
               legend2.Header = "CA";
               legend2.FontFamily = new FontFamily("Bradley Hand ITC");
               legend2.FontSize = 16;
               legend2.Items.Add(item);
               ....
               ....
               this.lineChart.Legend = legend2;
           }

Devi Aruna Maharasi Murugan [Syncfusion]
Replied On September 19, 2016 08:50 AM

Hi Jean, 
  
Thanks for contacting Syncfusion Support. 
  
We are able to achieve your requirement with LegendItem property of chart. We have prepared a demo sample for your requirement and it can be downloaded from below link, 
  
Sample: Lenged126001 
  
Regards, 
Devi 




Gregory
Replied On September 19, 2016 09:14 AM

It work great, thank you !

Devi Aruna Maharasi Murugan [Syncfusion]
Replied On September 19, 2016 11:38 PM

Hi Jean, 
  
Thanks for your update. 
  
Please contact us, if you need any further assistance. 
  
Regards, 
Devi 


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.

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.

;