Class ChartLegend
Represents legend for a SfChart.
Inheritance
Implements
Namespace: Syncfusion.UI.Xaml.Charts
Assembly: Syncfusion.SfChart.WPF.dll
Syntax
public class ChartLegend : ItemsControl, ICloneable
Remarks
Chart legend will be added as chart's child. Each item in legend contain key information about the ChartSeriesBase. Legend has all abilities such as docking, enabling or disabling desired series in a SfChart.
Examples
<syncfusion:SfChart>
<syncfusion:SfChart.Legend>
<syncfusion:ChartLegend/>
</syncfusion:SfChart.Legend>
<syncfusion:Series/>
</syncfusion:SfChart >
ChartLegend chartLegend = new ChartLegend();
ChartArea.Legend = chartLegend;
Constructors
ChartLegend()
Initializes a new instance of the ChartLegend class.
Declaration
public ChartLegend()
Fields
CheckBoxVisibilityProperty
Identifies the CheckBoxVisibility dependency property. The DependencyProperty for CheckBoxVisibility property.
Declaration
public static DependencyProperty CheckBoxVisibilityProperty
Field Value
| Type |
|---|
| System.Windows.DependencyProperty |
CornerRadiusProperty
Identifies the CornerRadius dependency property. The DependencyProperty for CornerRadius property.
Declaration
public static DependencyProperty CornerRadiusProperty
Field Value
| Type |
|---|
| System.Windows.DependencyProperty |
DockPositionProperty
The DependencyProperty for DockPosition property.
Declaration
public static readonly DependencyProperty DockPositionProperty
Field Value
| Type |
|---|
| System.Windows.DependencyProperty |
HeaderProperty
The DependencyProperty for Header property.
Declaration
public static readonly DependencyProperty HeaderProperty
Field Value
| Type |
|---|
| System.Windows.DependencyProperty |
HeaderTemplateProperty
The DependencyProperty for HeaderTemplate property.
Declaration
public static readonly DependencyProperty HeaderTemplateProperty
Field Value
| Type |
|---|
| System.Windows.DependencyProperty |
IconHeightProperty
Identifies the IconHeight dependency property. The DependencyProperty for IconHeight property.
Declaration
public static DependencyProperty IconHeightProperty
Field Value
| Type |
|---|
| System.Windows.DependencyProperty |
IconVisibilityProperty
Identifies the IconVisibility dependency property. The DependencyProperty for IconVisibility property.
Declaration
public static DependencyProperty IconVisibilityProperty
Field Value
| Type |
|---|
| System.Windows.DependencyProperty |
IconWidthProperty
Identifies the IconWidth dependency property. The DependencyProperty for IconWidth property.
Declaration
public static DependencyProperty IconWidthProperty
Field Value
| Type |
|---|
| System.Windows.DependencyProperty |
ItemMarginProperty
Identifies the ItemMargin dependency property. The DependencyProperty for ItemMargin property.
Declaration
public static DependencyProperty ItemMarginProperty
Field Value
| Type |
|---|
| System.Windows.DependencyProperty |
LegendPositionProperty
The DependencyProperty for LegendPosition property.
Declaration
public static readonly DependencyProperty LegendPositionProperty
Field Value
| Type |
|---|
| System.Windows.DependencyProperty |
OffsetXProperty
Identifies the OffsetX dependency property. The DependencyProperty for OffsetX property.
Declaration
public static readonly DependencyProperty OffsetXProperty
Field Value
| Type |
|---|
| System.Windows.DependencyProperty |
OffsetYProperty
Identifies the OffsetY dependency property. The DependencyProperty for OffsetY property.
Declaration
public static readonly DependencyProperty OffsetYProperty
Field Value
| Type |
|---|
| System.Windows.DependencyProperty |
OrientationProperty
The DependencyProperty for Orientation property.
Declaration
public static readonly DependencyProperty OrientationProperty
Field Value
| Type |
|---|
| System.Windows.DependencyProperty |
SeriesProperty
The DependencyProperty for Series property.
Declaration
public static readonly DependencyProperty SeriesProperty
Field Value
| Type |
|---|
| System.Windows.DependencyProperty |
ToggleSeriesVisibilityProperty
Identifies the ToggleSeriesVisibility dependency property. The DependencyProperty for ToggleSeriesVisibility property.
Declaration
public static DependencyProperty ToggleSeriesVisibilityProperty
Field Value
| Type |
|---|
| System.Windows.DependencyProperty |
Properties
CheckBoxVisibility
Gets or sets a value that determines whether to show/hide CheckBox in legend item.
Declaration
public Visibility CheckBoxVisibility { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Windows.Visibility | System.Windows.Visibility |
CornerRadius
Gets or sets the CornerRadius of legend's border.
Declaration
public CornerRadius CornerRadius { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Windows.CornerRadius |
DockPosition
Gets or sets the position of the ChartLegend.
Declaration
public ChartDock DockPosition { get; set; }
Property Value
| Type | Description |
|---|---|
| ChartDock |
Header
Gets or sets the header for the legend.
Declaration
public object Header { get; set; }
Property Value
| Type |
|---|
| System.Object |
HeaderTemplate
Gets or sets the legend header template.
Declaration
public DataTemplate HeaderTemplate { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Windows.DataTemplate | System.Windows.DataTemplate |
IconHeight
Gets or sets height of the legend icon.
Declaration
public double IconHeight { get; set; }
Property Value
| Type |
|---|
| System.Double |
IconVisibility
Gets or sets the visibility of the legend icon.
Declaration
public Visibility IconVisibility { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Windows.Visibility | System.Windows.Visibility |
IconWidth
Gets or sets width of the legend icon.
Declaration
public double IconWidth { get; set; }
Property Value
| Type |
|---|
| System.Double |
ItemMargin
Gets or sets the margin for legend item.
Declaration
public Thickness ItemMargin { get; set; }
Property Value
| Type |
|---|
| System.Windows.Thickness |
LegendPosition
Gets or sets the legend position in the chart.
Declaration
public LegendPosition LegendPosition { get; set; }
Property Value
| Type | Description |
|---|---|
| LegendPosition |
Remarks
This is works for 2D charts alone.
OffsetX
Gets or sets the value used to move the ChartLegend on x-coordinate.
Declaration
public double OffsetX { get; set; }
Property Value
| Type |
|---|
| System.Double |
Remarks
This property is working for dock position as Floating only.
OffsetY
Gets or sets the value used to move the ChartLegend on y-coordinate.
Declaration
public double OffsetY { get; set; }
Property Value
| Type |
|---|
| System.Double |
Remarks
This property is working for dock position as Floating only.
Orientation
Gets or sets the orientation of chart legend.
Declaration
public ChartOrientation Orientation { get; set; }
Property Value
| Type | Description |
|---|---|
| ChartOrientation |
Series
Gets or sets the series value to get data point based legend items.
Declaration
public ChartSeriesBase Series { get; set; }
Property Value
| Type |
|---|
| ChartSeriesBase |
ToggleSeriesVisibility
Gets or sets a value indicating whether ToggleSeriesVisibility is enabled.
Declaration
public bool ToggleSeriesVisibility { get; set; }
Property Value
| Type |
|---|
| System.Boolean |
Methods
Clone()
Returns the instance of ChartLegend class.
Declaration
public DependencyObject Clone()
Returns
| Type | Description |
|---|---|
| System.Windows.DependencyObject | object. |
OnCreateAutomationPeer()
Returns class-specific System.Windows.Automation.Peers.AutomationPeer implementations for the WPF infrastructure.
Declaration
protected override AutomationPeer OnCreateAutomationPeer()
Returns
| Type | Description |
|---|---|
| System.Windows.Automation.Peers.AutomationPeer | The type-specific System.Windows.Automation.Peers.AutomationPeer implementation. |
OnMouseDown(MouseButtonEventArgs)
Called when the mouse button pressed on the LegendItem.
Declaration
protected override void OnMouseDown(MouseButtonEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Input.MouseButtonEventArgs | e | Event args. |
OnMouseLeave(MouseEventArgs)
Called when the mouse leaved from the chart legend.
Declaration
protected override void OnMouseLeave(MouseEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Input.MouseEventArgs | e | Event args. |
OnMouseMove(MouseEventArgs)
Called when the mouse moved on the LegendItem.
Declaration
protected override void OnMouseMove(MouseEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Input.MouseEventArgs | e | Event args. |