Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

ChartControl.Legends Property

Returns a collection of additional legends.

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v24.2.UI.dll

NuGet Package: DevExpress.Win.Charts

#Declaration

public LegendCollection Legends { get; }

#Property Value

Type Description
LegendCollection

A collection of Legend objects.

#Example

To add an additional legend to a chart, create a new instance of the Legend class and add it to the ChartControl.Legends collection. Configure its Legend.DockTarget, LegendBase.AlignmentVertical and LegendBase.AlignmentHorizontal properties to position the legend to the required place.

Note

Note that the legend will not be shown until it is assigned to the SeriesBase.Legend, Indicator.Legend, ConstantLine.Legend or Strip.Legend property.

View Example

// Create a new instance of Legend.
Legend macdLegend = new Legend();
chart.Legends.Add(macdLegend);
// Position it.
macdLegend.DockTarget = diagram.Panes.GetPaneByName("macdPane");
macdLegend.AlignmentHorizontal = LegendAlignmentHorizontal.Left;
macdLegend.AlignmentVertical = LegendAlignmentVertical.Top;

// Assign the data displayed in legend.
macd.Legend = macdLegend;
See Also