To add an additional legend to a chart, create a new instance of the DevExpress.XtraCharts.Legend class and add it to the Legends collection.
Configure its DevExpress.XtraCharts.Legend.DockTarget, DevExpress.XtraCharts.Legend.AlignmentVertical and DevExpress.XtraCharts.Legend.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.
Form1.cs |
Legend macdLegend = new Legend();
chart.Legends.Add(macdLegend);
macdLegend.DockTarget = diagram.Panes.GetPaneByName("macdPane");
macdLegend.AlignmentHorizontal = LegendAlignmentHorizontal.Left;
macdLegend.AlignmentVertical = LegendAlignmentVertical.Top;
macd.Legend = macdLegend;
|
Form1.vb |
' Create a new instance of Legend.
Dim macdLegend As 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
|