Articles in this section
Category / Section

How to work with the items in the ChartLegend using Series?

1 min read

 

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"

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied