Class ChartLegend
Represents the legend in SfChart. This class can be used to customize the appearance of legend items.
Inheritance
Namespace: Syncfusion.SfChart.XForms
Assembly: Syncfusion.SfChart.XForms.dll
Syntax
public class ChartLegend : Element, IThemeElement
Remarks
Chart legend will be added as chart's child. Each item in legend contain key information about the Series. Legend has all abilities such as docking, enabling or disabling desired series in a SfChart.
Examples
SfChart chart = new SfChart();
chart.Legend = new ChartLegend();
Constructors
ChartLegend()
Initializes a new instance of the ChartLegend class.
Declaration
public ChartLegend()
Fields
BackgroundColorProperty
Gets or sets the color value for the legend background. This is a bindable property.
Declaration
public static readonly BindableProperty BackgroundColorProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
CornerRadiusProperty
Gets or sets a value that defines the rounded corners for legend border. This is a bindable property.
Declaration
public static readonly BindableProperty CornerRadiusProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
DockPositionProperty
Gets or sets placement of the legend inside the chart. This is a bindable property.
Declaration
public static readonly BindableProperty DockPositionProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
IconHeightProperty
Gets or sets the height of the legend icon. This is a bindable property.
Declaration
public static readonly BindableProperty IconHeightProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
IconWidthProperty
Gets or sets the width of the legend icon. This is a bindable property.
Declaration
public static readonly BindableProperty IconWidthProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
IsIconVisibleProperty
Gets or sets the value that indicates whether to display the legend icon.
Declaration
public static readonly BindableProperty IsIconVisibleProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
IsVisibleProperty
The DependencyProperty for IsVisible property.
Declaration
public static readonly BindableProperty IsVisibleProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
ItemMarginProperty
Gets or sets the margin of the legend items. This is a bindable property.
Declaration
public static readonly BindableProperty ItemMarginProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
ItemTemplateProperty
Gets or sets a data template for all series legend item. This is a bindable property.
Declaration
public static readonly BindableProperty ItemTemplateProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
LabelStyleProperty
Gets or sets the customized style for the label inside the legend item. This is a bindable property.
Declaration
public static readonly BindableProperty LabelStyleProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
MarginProperty
Gets or sets a value that defines the margin for legend. This is a bindable property.
Declaration
public static readonly BindableProperty MarginProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
MaxWidthProperty
Gets or sets double value that used to customize the legend ItemsLayout width, when the ChartLegendOverflowMode. value is Wrap. This is a bindable property.
Declaration
public static readonly BindableProperty MaxWidthProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
OffsetXProperty
Gets or sets the horizontal offset value for the legend. Works when the DockPosition
property set to Floating
. This is a bindable property.
Declaration
public static readonly BindableProperty OffsetXProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
OffsetYProperty
Gets or sets the vertical offset value for the legend. Works when the DockPosition
property set to Floating
. This is a bindable property.
Declaration
public static readonly BindableProperty OffsetYProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
OrientationProperty
Gets or sets the orientation of the legend items. This is a bindable property.
Declaration
public static readonly BindableProperty OrientationProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
OverflowModeProperty
Gets or sets enum ChartLegendOverflowMode value that indicates items overflow action in legend. This is a bindable property.
Declaration
public static readonly BindableProperty OverflowModeProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
SeriesProperty
Gets or sets the series value to generate legend items based on the data points of this series. This is a bindable property.
Declaration
public static readonly BindableProperty SeriesProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
StrokeColorProperty
Gets or sets the color value for the legend border. This is a bindable property.
Declaration
public static readonly BindableProperty StrokeColorProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
StrokeDashArrayProperty
Gets or sets the dash array for the legend border. This is a bindable property.
Declaration
public static readonly BindableProperty StrokeDashArrayProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
StrokeWidthProperty
Gets or sets the width of the legend border line. This is a bindable property.
Declaration
public static readonly BindableProperty StrokeWidthProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
TitleProperty
Gets or sets the title for the legend. This is a mutable property.
Declaration
public static readonly BindableProperty TitleProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
ToggleSeriesVisibilityProperty
The DependencyProperty for ToggleSeriesVisibility property.
Declaration
public static readonly BindableProperty ToggleSeriesVisibilityProperty
Field Value
Type |
---|
Xamarin.Forms.BindableProperty |
Properties
BackgroundColor
Gets or sets the color value for the legend background. This is a bindable property.
Declaration
public Color BackgroundColor { get; set; }
Property Value
Type | Description |
---|---|
Xamarin.Forms.Color | This property takes the Xamarin.Forms.Color value. |
CornerRadius
Gets or sets a value that defines the rounded corners for legend border. This is a bindable property.
Declaration
public ChartCornerRadius CornerRadius { get; set; }
Property Value
Type | Description |
---|---|
ChartCornerRadius | This property takes the ChartCornerRadius value. |
DockPosition
Gets or sets placement of the legend inside the chart. This is a bindable property.
Declaration
public LegendPlacement DockPosition { get; set; }
Property Value
Type | Description |
---|---|
LegendPlacement | This property takes the LegendPlacement as its value. |
IconHeight
Gets or sets the height of the legend icon. This is a bindable property.
Declaration
public double IconHeight { get; set; }
Property Value
Type | Description |
---|---|
System.Double | This property takes double value. |
IconWidth
Gets or sets the width of the legend icon. This is a bindable property.
Declaration
public double IconWidth { get; set; }
Property Value
Type | Description |
---|---|
System.Double | This property takes double value. |
IsIconVisible
Gets or sets a value indicating whether to display the legend icon.
Declaration
public bool IsIconVisible { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | This property takes the boolean value. |
IsVisible
Gets or sets a value indicating whether the legend is visible in the chart. This is a bindable property.
Declaration
public bool IsVisible { get; set; }
Property Value
Type |
---|
System.Boolean |
ItemMargin
Gets or sets the margin of the legend items. This is a bindable property.
Declaration
public Thickness ItemMargin { get; set; }
Property Value
Type | Description |
---|---|
Xamarin.Forms.Thickness | This property takes |
ItemTemplate
Gets or sets the data template for legend item.
Declaration
public DataTemplate ItemTemplate { get; set; }
Property Value
Type | Description |
---|---|
Xamarin.Forms.DataTemplate | This property takes the DataTemplate value. |
LabelStyle
Gets or sets the customized style for the label inside the legend item. This is a bindable property.
Declaration
public ChartLegendLabelStyle LabelStyle { get; set; }
Property Value
Type | Description |
---|---|
ChartLegendLabelStyle | This property takes the ChartLegendLabelStyle as its value. |
Margin
Gets or sets a value that defines the margin for legend. This is a bindable property.
Declaration
public Thickness Margin { get; set; }
Property Value
Type |
---|
Xamarin.Forms.Thickness |
MaxWidth
Gets or sets double value that used to customize the legend ItemsLayout width, when the ChartLegendOverflowMode. value is Wrap. This is a bindable property.
Declaration
public double MaxWidth { get; set; }
Property Value
Type |
---|
System.Double |
OffsetX
Gets or sets the horizontal offset value for the legend. Works when the DockPosition
property set to Floating
. This is a bindable property.
Declaration
public double OffsetX { get; set; }
Property Value
Type | Description |
---|---|
System.Double | This property takes double value. |
Remarks
This property having effect only with DockPosition value as Floating
.
OffsetY
Gets or sets the vertical offset value for the legend. Works when the DockPosition
property set to Floating
. This is a bindable property.
Declaration
public double OffsetY { get; set; }
Property Value
Type | Description |
---|---|
System.Double | This property takes double value. |
Remarks
This property having effect only with DockPosition value as Floating
.
Orientation
Gets or sets the orientation of the legend items. This is a bindable property.
Declaration
public ChartOrientation Orientation { get; set; }
Property Value
Type | Description |
---|---|
ChartOrientation | This property takes ChartOrientation as its value. |
OverflowMode
Gets or sets enum ChartLegendOverflowMode value that indicates items overflow action in legend. This is a bindable property.
Declaration
public ChartLegendOverflowMode OverflowMode { get; set; }
Property Value
Type | Description |
---|---|
ChartLegendOverflowMode | This property takes the ChartLegendOverflowMode as its value. |
Series
Gets or sets the series value to get legend items based on data points of this series. This is a bindable property.
Declaration
public ChartSeries Series { get; set; }
Property Value
Type |
---|
ChartSeries |
Remarks
If we set legend items based on data points of this series, then ToggleSeriesVisibility will not works for cartesian and polar series.
StrokeColor
Gets or sets the border stroke color of the legend. This is a bindable property.
Declaration
public Color StrokeColor { get; set; }
Property Value
Type | Description |
---|---|
Xamarin.Forms.Color | This property takes the Xamarin.Forms.Color value. |
StrokeDashArray
Gets or sets the dash array for the legend border. This is a bindable property.
Declaration
public double[] StrokeDashArray { get; set; }
Property Value
Type | Description |
---|---|
System.Double[] | This property takes the double array as its value. |
StrokeWidth
Gets or sets the width of the legend border stroke line. This is a bindable property.
Declaration
public double StrokeWidth { get; set; }
Property Value
Type | Description |
---|---|
System.Double | This property takes the System.Double value. |
Title
Gets or sets the title for the legend. This is a mutable property.
Declaration
public ChartTitle Title { get; set; }
Property Value
Type |
---|
ChartTitle |
ToggleSeriesVisibility
Gets or sets a value indicating whether to bind the series visibility with its corresponding legend item in the legend. This is bindable property.
Declaration
public bool ToggleSeriesVisibility { get; set; }
Property Value
Type |
---|
System.Boolean |
Methods
OnBindingContextChanged()
Override this method to execute an action when the BindingContext changes.
Declaration
protected override void OnBindingContextChanged()
OnParentSet()
Declaration
protected override void OnParentSet()