Articles in this section
Category / Section

How to create multiple legends for a chart control?

1 min read

 

Essential Chart supports multiple legends in single chart control. It is used to view legend items more clearly when we have more number of series. To have multiple legends we need to create custom legends and add the series to it.

When we use custom legends we can also use default legend too. If we are not in need to default legend we can set ShowLegend property to false.

C#

// Creating Legends

ChartLegend legend1 = new ChartLegend(chartControl1);

ChartLegend legend2 = new ChartLegend(chartControl1);

legend1.Name = "legend1";

legend2.Name = "legend2";

legend1.Position = ChartDock.Bottom;

legend2.Position = ChartDock.Right;

//Adding to Chart Control

chartControl1.Legends.Add(legend1);

chartControl1.Legends.Add(legend2);

s1.LegendName = "legend1";

s5.LegendName = "legend2";

VB

' Creating Legends

Dim legend1 As ChartLegend = New ChartLegend(ChartControl1)

Dim legend2 As ChartLegend = New ChartLegend(ChartControl1)

legend1.Name = "legend1"

legend2.Name = "legend2"

legend1.Position = ChartDock.Bottom

legend2.Position = ChartDock.Right

' Adding to Chart Control

ChartControl1.Legends.Add(legend1)

ChartControl1.Legends.Add(legend2)

s1.LegendName = "legend1"

s5.LegendName = "legend2"

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