Class ChartLegend
Represents the legend for the SfCartesianChart, SfCircularChart, SfFunnelChart and SfPyramidChart classes.
Inheritance
Namespace: Syncfusion.Maui.Charts
Assembly: Syncfusion.Maui.Charts.dll
Syntax
public class ChartLegend : BindableObject, ILegend
Remarks
The items in the legend contain the key information about the ChartSeries. The legend has all abilities such as docking, enabling, or disabling the desired series.
Examples
<chart:SfCartesianChart>
<chart:SfCartesianChart.Legend>
<chart:ChartLegend/>
</chart:SfCartesianChart.Legend>
</chart:SfCartesianChart>
Constructors
ChartLegend()
Declaration
public ChartLegend()
Fields
IsVisibleProperty
Identifies the IsVisible bindable property.
Declaration
public static readonly BindableProperty IsVisibleProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
ItemTemplateProperty
Identifies the ItemTemplate bindable property.
Declaration
public static readonly BindableProperty ItemTemplateProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
PlacementProperty
Identifies the Placement bindable property.
Declaration
public static readonly BindableProperty PlacementProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
ToggleSeriesVisibilityProperty
Identifies the ToggleSeriesVisibility bindable property.
Declaration
public static readonly BindableProperty ToggleSeriesVisibilityProperty
Field Value
Type | Description |
---|---|
Microsoft.Maui.Controls.BindableProperty |
Properties
IsVisible
Gets or sets a value that indicates whether the legend is visible or not.
Declaration
public bool IsVisible { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | It accepts bool values and the default value is |
Examples
<chart:SfCircularChart>
<chart:SfCircularChart.Legend>
<chart:ChartLegend IsVisible = "True"/>
</chart:SfCircularChart.Legend>
<chart:PieSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"/>
</chart:SfCircularChart>
ItemTemplate
Gets or sets a template to customize the appearance of each legend item.
Declaration
public DataTemplate ItemTemplate { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.Controls.DataTemplate | It accepts Microsoft.Maui.Controls.DataTemplate value. |
Examples
<chart:SfCircularChart>
<chart:SfCircularChart.Legend>
<chart:ChartLegend>
<chart:ChartLegend.ItemTemplate>
<DataTemplate>
<StackLayout Orientation="Horizontal" >
<Rectangle HeightRequest="12" WidthRequest="12" Margin="3"
Background="{Binding IconBrush}"/>
<Label Text="{Binding Text}" Margin="3"/>
</StackLayout>
</DataTemplate>
</chart:ChartLegend.ItemTemplate>
</chart:ChartLegend>
</chart:SfCircularChart.Legend>
<chart:PieSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"/>
</chart:SfCircularChart>
Placement
Gets or sets the placement for the legend in a chart.
Declaration
public LegendPlacement Placement { get; set; }
Property Value
Type | Description |
---|---|
LegendPlacement | It accepts LegendPlacement values and the default value is Top. |
Remarks
Legends can be placed left, right, top, or bottom around the chart area.
Examples
<chart:SfCircularChart>
<chart:SfCircularChart.Legend>
<chart:ChartLegend Placement = "Right"/>
</chart:SfCircularChart.Legend>
<chart:PieSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"/>
</chart:SfCircularChart>
ToggleSeriesVisibility
Gets or sets a value indicating whether the chart series visibility by tapping the legend item.
Declaration
public bool ToggleSeriesVisibility { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | It accepts bool values and the default value is |
Examples
<chart:SfCircularChart>
<chart:SfCircularChart.Legend>
<chart:ChartLegend ToggleSeriesVisibility = "True"/>
</chart:SfCircularChart.Legend>
<chart:PieSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"/>
</chart:SfCircularChart>