Legend
- 3 minutes to read
Legend is a chart element that displays series and series points’ designations:
Note that a legend’s content depends on a chart that displays a legend:
The legend displays items that refer to series when the DXChart shows a legend. A legend item’s text contains DXSeriesBase.displayName in this case.
The legend displays items for series points if the DXPieChart shows a legend. The DXSeriesBase.legendTextPattern property configures the legend items’ text.
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.
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.
Gets or sets a chart’s legend settings. | |
The chart legend options storage. | |
Gets or sets a legend’s horizontal position. | |
Gets or sets a legend’s vertical position. | |
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:
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:
Gets or sets a legend’s style options. | |
The legend’s appearance settings storage. |