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

How to customize the items in the ChartLegend?

Platform: WinForms |
Control: Chart


The chart legend can be displayed by setting ShowLegend property as true. Essential Chart supports various properties to customize legend items. ItemsAlignment property is used to specify the alignment of Items in legend. ShowItemShadow property is used to display shadow in items. TextAlignment property is used to align text in legend.


// Aligns Items in the legend

this.chartControl1.Legend.ItemsAlignment = StringAlignment.Center;

// Displays Shadow

this.chartControl1.Legend.ShowItemsShadow = true;

this.chartControl1.Legend.ItemsShadowColor = Color.Red;

this.chartControl1.Legend.ItemsShadowOffset = new Size(2, 2);

this.chartControl1.Legend.ItemsSize = new Size(20, 20);

// Aligns text in the legend

this.chartControl1.Legend.ItemsTextAligment = VerticalAlignment.Top;


' Aligns Items in the legend

Me.ChartControl1.Legend.ItemsAlignment = StringAlignment.Center

' Displays Shadow

Me.ChartControl1.Legend.ShowItemsShadow = True

Me.ChartControl1.Legend.ItemsShadowColor = Color.Red

Me.ChartControl1.Legend.ItemsShadowOffset = New Size(2, 2)

Me.ChartControl1.Legend.ItemsSize = New Size(20, 20)

' Aligns text in the legend

Me.ChartControl1.Legend.ItemsTextAligment = VerticalAlignment.Top

It is also possible to show the custom legend items in Legend. To display custom legend items we need to create an instance of ChartLegendItem class. To display a custom legend item we need to set the visible property to false for the default legend item.

We can customize the style of the legend item also. ShowSymbol, ShowShadow allows us to display or hide the symbol and shadow respectively. We can edit the symbol by using Symbol.Color, Symbol.Shape etc. Using CustomItems under Legend property we can add the item into Legend.


// Hidding default legend item

series2.LegendItem.Visible = false;

// Creating new custom legend item

ChartLegendItem item1 = new ChartLegendItem();

// Setting its properties

item1.ItemStyle.BorderColor = Color.Fuchsia;

item1.ItemStyle.ShowShadow = false;

item1.ItemStyle.ShowSymbol = true;

item1.ItemStyle.Symbol.Color = Color.LightCyan;

item1.ItemStyle.Symbol.Shape = ChartSymbolShape.Diamond;

item1.Text = "Server2";

item1.ItemStyle.TextColor = Color.Green;

// Adding it into chart legend

this.chartControl1.Legend.CustomItems = new ChartLegendItem[] { item1 };


' Hidding default legend item

series2.LegendItem.Visible = False

' Creating new custom legend item

Dim item1 As ChartLegendItem = New ChartLegendItem()

' Setting its properties

item1.ItemStyle.BorderColor = Color.Fuchsia

item1.ItemStyle.ShowShadow = False

item1.ItemStyle.ShowSymbol = True

item1.ItemStyle.Symbol.Color = Color.LightCyan

item1.ItemStyle.Symbol.Shape = ChartSymbolShape.Diamond

item1.Text = "Server2"

item1.ItemStyle.TextColor = Color.Green

' Adding it into chart legend

Me.ChartControl1.Legend.CustomItems = New ChartLegendItem() {item1}

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

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

Up arrow icon

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