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 work with the items in the ChartLegend using Series?

 

The chart legend can be displayed by setting ShowLegend property to true. Using Chart control series we can customize its respective legend items. The instance of legend item can be created using ChartSeriesLegendItem class.

IconAlignment property is used to align the icons in legend. Symbol can be displayed when setting the ShowSymbol property to true. Legend Item can be hidden by setting Visible property to false.

C#

// Creating an instance to ChartSeriesLegendItem Class

ChartSeriesLegendItem item1 = this.chartControl1.Series[0].LegendItem;

item1.Series.LegendItem.IconAlignment = LeftRightAlignment.Right;

// Disable shadow

item1.Series.LegendItem.ItemStyle.ShowShadow = false;

item1.Series.LegendItem.ItemStyle.TextColor = Color.Green;

// Setting Font

item1.Series.LegendItem.ItemStyle.Font = new Font("Verdana", 10f, FontStyle.Italic);

// Setting Symbol Properties

item1.Series.LegendItem.ShowSymbol = true;

item1.Series.LegendItem.Symbol.Color = Color.LightBlue;

item1.Series.LegendItem.Symbol.Shape = ChartSymbolShape.Hexagon;

item1.Series.LegendItem.Text = "MySeries";

VB

' Creating an instance to ChartSeriesLegendItem Class

Dim item1 As ChartSeriesLegendItem = Me.ChartControl1.Series(0).LegendItem

item1.Series.LegendItem.IconAlignment = LeftRightAlignment.Right

' Disable shadow

item1.Series.LegendItem.ItemStyle.ShowShadow = False

item1.Series.LegendItem.ItemStyle.TextColor = Color.Green

' Setting Font

item1.Series.LegendItem.ItemStyle.Font = New Font("Verdana", 10.0F, FontStyle.Italic)

' Setting Symbol Properties

item1.Series.LegendItem.ShowSymbol = True

item1.Series.LegendItem.Symbol.Color = Color.LightBlue

item1.Series.LegendItem.Symbol.Shape = ChartSymbolShape.Hexagon

item1.Series.LegendItem.Text = "MySeries"

Article ID: Published Date: Last Revised Date: Platform: Control:
57 04/30/2011 07/10/2014 Windows Forms Chart
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

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.