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

How to create custom legend item


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;
               this.lineChart.Legend = legend2;

3 Replies

DA Devi Aruna Maharasi Murugan Syncfusion Team September 19, 2016 12:50 PM UTC

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 

GR Gregory September 19, 2016 01:14 PM UTC

It work great, thank you !

DA Devi Aruna Maharasi Murugan Syncfusion Team September 20, 2016 03:38 AM UTC

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

Live Chat Icon For mobile
Up arrow icon