Skip to main content
A newer version of this page is available.

Legend

  • 3 minutes to read

Legend is a chart element that displays series and series points’ designations:

Legend example

Note that a legend’s content depends on a chart that displays a legend:

How to: Change a legend’s position and layout

You can place a legend all around the chart area; for example, at the top-center, either horizontally or vertically. The image below shows a legend placed at the top-center with a horizontal layout.

TopOutside-Centered horizontal legend

See this code to learn how to obtain the image:

DXLegend *legend = [[DXLegend alloc] init];
legend.horizontalPosition = DXLegendHorizontalPositionCenter;
legend.verticalPosition = DXLegendVerticalPositionTopOutside;
legend.orientation = DXLegendOrientationLeftToRight;
self.chart.legend = legend;

Use the following symbols to configure a legend’s layout and position.

DXChartBase.legend

Gets or sets a chart’s legend settings.

DXLegend

The chart legend options storage.

DXLegend.horizontalPosition

Gets or sets a legend’s horizontal position.

DXLegend.verticalPosition

Gets or sets a legend’s vertical position.

DXLegend.orientation

Gets or sets a legend’s layout orientation.

How to: Show or hide a series in a legend

Use the DXSeriesBase.showInLegend property, to show or hide an individual series in a legend:

series.showInLegend = NO;

How to: Configure a legend’s appearance

You can style a legend like any other chart element. Below are changeable appearance parameters:

Styleable legend elements

See the code snippet below to learn how to change this legend’s style:

// All sizes are in screen points.
DXLegendStyle *style = [[DXLegendStyle alloc] init];
DXTextStyle *textStyle = [[DXTextStyle alloc] init];

style.borderColor = [UIColor colorWithWhite:0.4 alpha:1];
style.borderThickness = 5;
style.backgroundColor = [UIColor colorWithWhite:0.1647 alpha:1];
style.markerSize = 30;
style.textIndent = 25;
style.itemsHorizontalIndent = 25;
style.textStyle = textStyle;

textStyle.fontSize = 30;
textStyle.foregroundColor = [UIColor colorWithWhite:0.5 alpha:1];

legend.style = style;

The following symbols allow you to customize the legend’s appearance:

DXLegend.style

Gets or sets a legend’s style options.

DXLegendStyle

The legend’s appearance settings storage.