Legend.VerticalPosition Property
Gets or sets the vertical position of the legend relative to the chart diagram.
Namespace: DevExpress.XamarinForms.Charts
Assembly: DevExpress.XamarinForms.Charts.dll
NuGet Package: DevExpress.XamarinForms.Charts
Declaration
public LegendVerticalPosition VerticalPosition { get; set; }
Property Value
Type | Description |
---|---|
LegendVerticalPosition | A LegendVerticalPosition enumeration value that specifies the legend’s vertical position. |
Available values:
Name | Description |
---|---|
Center | The legend is centered vertically inside the chart diagram. |
Top | The legend is positioned inside the chart diagram and aligned to the top. |
TopOutside | The legend is positioned above the chart diagram. |
Bottom | The legend is positioned inside the chart diagram and aligned to the bottom. |
BottomOutside | The legend is positioned under the chart diagram. |
Remarks
Use the VerticalPosition property to specify the vertical alignment of the legend. You can place it at the top or bottom of the chart, inside or outside the diagram.
To specify the horizontal position of the legend, use the HorizontalPosition property.
Example
This example shows how to add a legend to a pie chart and adjust the legend settings.
To add a legend to the chart, assign a Legend object to the PieChartView.Legend property and use the following properties of this object to specify the legend orientation and position:
- Orientation - display legend items in a row, from left to right.
VerticalPosition
- place the legend above the chart diagram.- HorizontalPosition - align the legend horizontally to the center.
Set the Legend.Style property to a LegendStyle object and specify the following properties of this object to configure the legend appearance:
- BorderColor and BorderThickness - configure the legend border.
- BackgroundColor - specify the background color.
- MarkerSize and TextIndent - change the size of markers, and set the distance between an item text and marker.
- ItemsHorizontalIndent - specify the distance between legend items.
- Padding - specify the distance between legend edges and content.
- TextStyle - change the item text color and size.
To exclude points of the chart’s first series from the legend, set the VisibleInLegend property of this series to false.
<dxc:PieChartView x:Name="chartView">
<dxc:PieChartView.Series>
<dxc:DonutSeries Data="{Binding SecuritiesByTypes}" VisibleInLegend="False"/>
<dxc:DonutSeries Data="{Binding SecuritiesByRisk}"/>
</dxc:PieChartView.Series>
<dxc:PieChartView.Legend>
<dxc:Legend Orientation="LeftToRight"
VerticalPosition="TopOutside"
HorizontalPosition="Center">
<dxc:Legend.Style>
<dxc:LegendStyle BorderColor="LightGray" BorderThickness="3"
BackgroundColor="Gray"
MarkerSize="30" TextIndent="10"
ItemsHorizontalIndent="50"
Padding="150,150,10,10">
<dxc:LegendStyle.TextStyle>
<dxc:TextStyle Color="White" Size="24"/>
</dxc:LegendStyle.TextStyle>
</dxc:LegendStyle>
</dxc:Legend.Style>
</dxc:Legend>
</dxc:PieChartView.Legend>
</dxc:PieChartView>