menu

Blazor

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class ChartLegendSettings - Blazor API Reference | Syncfusion

    Show / Hide Table of Contents

    Class ChartLegendSettings

    Represents the settings for a chart legend.

    Inheritance
    System.Object
    ChartSubComponent
    ChartLegendSettings
    Implements
    ILegendBase
    Inherited Members
    ChartSubComponent.BuildRenderTree(RenderTreeBuilder)
    ChartSubComponent.ChildContent
    ChartSubComponent.Dispose(Boolean)
    ChartSubComponent.OnParametersSet()
    Namespace: Syncfusion.Blazor.Charts
    Assembly: Syncfusion.Blazor.dll
    Syntax
    public class ChartLegendSettings : ChartSubComponent, ISubcomponentTracker, ILegendBase

    Constructors

    ChartLegendSettings()

    Declaration
    public ChartLegendSettings()

    Properties

    AccessibilityDescriptionFormat

    Gets or sets the format for the legend item accessibility description of the ChartLegendSettings.

    Declaration
    public string AccessibilityDescriptionFormat { get; set; }
    Property Value
    Type Description
    System.String

    Accepts a string that defines the format for the legend item accessibility description of the ChartLegendSettings. The default value is null.

    Remarks

    Use this property to specify a format for the legend item accessibility description of the ChartLegendSettings. The placeholder ${value} can be used to set the accessibility text for the legend item. For example, the format "Selected the ${value} legend" will read as "Selected the Product A legend" for the legend item with text "Product A".

    AccessibilityRole

    Gets or sets the accessibility role for the ChartLegendSettings.

    Declaration
    public string AccessibilityRole { get; set; }
    Property Value
    Type Description
    System.String

    Accepts a string that defines the accessibility role for the ChartLegendSettings. The default value is null.

    Remarks

    Use this property to provide an accessibility role for the ChartLegendSettings.

    Alignment

    Gets or sets the alignment of the legend.

    Declaration
    public Alignment Alignment { get; set; }
    Property Value
    Type Description
    Alignment

    One of the Alignment enumerations that specifies the legend alignment. Options include:

    • Near: Aligns the legend to the left or top based on the Position.
    • Center: Aligns the legend to the center of the chart.
    • Far: Aligns the legend to the right or bottom based on the Position.
      The default value is Alignment.Center.
    Remarks

    The alignment of the legend works as follows:

    • Near: Aligns the legend to the top-left of the chart if Position is LegendPosition.Top and to the right-top of the chart if Position is LegendPosition.Right.
    • Center: Aligns the legend to the top center of the chart if Position is LegendPosition.Top and to the right center of the chart if Position is LegendPosition.Right.
    • Far: Aligns the legend to the top-right of the chart if Position is LegendPosition.Top and to the right-bottom of the chart if Position is LegendPosition.Right.

    Background

    Gets or sets the background color of the chart legend area.

    Declaration
    public string Background { get; set; }
    Property Value
    Type Description
    System.String

    A string value specifying the background color of the chart legend area. The default value is "transparent".

    Remarks

    The value can be specified in hex or rgba format, following valid CSS color string conventions.

    Border

    Gets or sets an instance of ChartLegendBorder that specifies the border of the legend.

    Declaration
    public ChartLegendBorder Border { get; set; }
    Property Value
    Type Description
    ChartLegendBorder

    The default value is an instance of ChartLegendBorder.

    Remarks

    Use this property to customize the border of the legend, allowing adjustments to properties such as color, width, and style to enhance visual appeal.

    Description

    Gets or sets the description for accessibility purposes, particularly when focused on the legend element by screen readers.

    Declaration
    public string Description { get; set; }
    Property Value
    Type Description
    System.String

    A string representing the description for legends.

    Remarks

    This property is primarily for enhancing accessibility, providing a textual description that screen readers can announce when the legend is focused.

    EnableHighlight

    Gets or sets a value indicating whether to enable highlighting when hovered over the legend element.

    Declaration
    public bool EnableHighlight { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if highlight options are enabled; otherwise, false. The default value is false.

    Remarks

    If set to true, when hovered over the legend element, the respective series will be highlighted.

    Focusable

    Gets or sets the accessibility keyboard navigation focus option for the ChartLegendSettings.

    Declaration
    public bool Focusable { get; set; }
    Property Value
    Type Description
    System.Boolean

    Accepts the boolean value to enable or disable the keyboard navigation for the ChartLegendSettings. The default value is true.

    Remarks

    Use this property to toggle the keyboard navigation focus for the ChartLegendSettings.

    Height

    Gets or sets the height for the legend element.

    Declaration
    public string Height { get; set; }
    Property Value
    Type Description
    System.String

    A string representing the height of the legend element. The default value is null. Based on the legend position, the height of the legend will be calculated.

    Remarks

    Accepts values in either pixels or percentage.

    IsInversed

    Gets or sets a value indicating whether to inverse legend item content (image and text).

    Declaration
    public bool IsInversed { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if the legend content should be inversed; otherwise, false. The default value is false.

    Remarks

    When set to true, the legend element will display the text before the associated shape. This is different from the default, where the shape is shown first, followed by the text.

    ItemPadding

    Gets or sets the padding between legend items.

    Declaration
    public double ItemPadding { get; set; }
    Property Value
    Type Description
    System.Double

    A double representing the padding between legend items. The default value is NaN.

    Remarks

    This property provides the spacing between items in the legend.

    Location

    Gets or sets an instance of ChartLocation that specifies the location of the legend relative to the chart. If x is set to 20, the legend will move 20 pixels to the right of the chart.

    Declaration
    public ChartLocation Location { get; set; }
    Property Value
    Type Description
    ChartLocation

    The default value is an instance of ChartLocation.

    Remarks

    The Position must be set to LegendPosition.Custom to position the legend in the chart using the specified x and y offsets.

    Margin

    Gets or sets an instance of ChartLegendMargin which specifies the margin for the legend.

    Declaration
    public ChartLegendMargin Margin { get; set; }
    Property Value
    Type Description
    ChartLegendMargin

    The default value is an instance of ChartLegendMargin allowing customization of left, right, top, and bottom margins.

    Remarks

    The ChartLegendMargin class provides options to customize the left, right, top, and bottom margins of the chart legend. Adjusting these margins controls the space between the legend and the surrounding elements.

    MaximumLabelWidth

    Gets or sets the maximum width of the individual legend item after which they get trimmed, wrapped, or clipped.

    Declaration
    public double MaximumLabelWidth { get; set; }
    Property Value
    Type Description
    System.Double

    Specifies the maximum width for the legend text. The default value is null.

    Remarks

    This property is used to control the maximum width of the labels in the legend items, ensuring that the text does not exceed the specified width, when TextOverflow or TextWrap properties are set.

    Opacity

    Gets or sets the opacity of the legend background.

    Declaration
    public double Opacity { get; set; }
    Property Value
    Type Description
    System.Double

    A double representing the opacity of the legend background. The default value is 1.

    Remarks

    The provided background color will be rendered with the applied opacity value.

    Padding

    Gets or sets the padding around the legend collection.

    Declaration
    public double Padding { get; set; }
    Property Value
    Type Description
    System.Double

    A double representing the padding around the legend collection. The default value is 8.

    Remarks

    This property is used to adjust the space around the legend to enhance layout.

    Position

    Gets or sets the position of the legend in the chart.

    Declaration
    public LegendPosition Position { get; set; }
    Property Value
    Type Description
    LegendPosition

    One of the LegendPosition enumeration that specifies the position of the legend. The options include:

    • Auto: Places the legend based on based on width and height
    • Top : Displays the legend at the top of the chart.
    • Left : Displays the legend at the left of the chart.
    • Bottom: Displays the legend at the bottom of the chart.
    • Right: Displays the legend at the right of the chart.
    • Custom: Displays the legend based on the given x and y location values.
      The default mode is LegendPosition.Auto.

    Reverse

    Gets or sets a value indicating whether to reverse the order of legend items.

    Declaration
    public bool Reverse { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if the legend items should be reversed; otherwise, false. The default value is false.

    Remarks

    If set to true, the last series in the collection will be placed first.

    ShapeHeight

    Gets or sets the height of the legend shape.

    Declaration
    public double ShapeHeight { get; set; }
    Property Value
    Type Description
    System.Double

    A double representing the height of the legend shape. The default value is 10.

    Remarks

    This property is used to modify the height of the legend shape.

    ShapePadding

    Gets or sets the padding between the legend shape and legend text.

    Declaration
    public double ShapePadding { get; set; }
    Property Value
    Type Description
    System.Double

    A double representing the padding between the legend shape and legend text. The default value is 8.

    Remarks

    This property allows for the adjustment of space between the legend shape and the text associated with it, enhancing the visual layout of the legend.

    ShapeWidth

    Gets or sets the width of the legend shape.

    Declaration
    public double ShapeWidth { get; set; }
    Property Value
    Type Description
    System.Double

    A double representing the width of the legend shape. The default value is 10.

    Remarks

    This property is used to modify the width of the legend shape.

    TabIndex

    Gets or sets the tabindex value of the legend for accessibility purposes.

    Declaration
    public double TabIndex { get; set; }
    Property Value
    Type Description
    System.Double

    A double representing the tabindex value for the legend. The default value is 3.

    Remarks

    This property is intended to provide a textual description of the legend for assistive technologies, improving accessibility for users with disabilities.

    TextOverflow

    Gets or sets the text overflow behavior to employ when the individual legend text overflows the legend bounds or MaximumLabelWidth.

    Declaration
    public LabelOverflow TextOverflow { get; set; }
    Property Value
    Type Description
    LabelOverflow

    One of the LabelOverflow enumeration values that specifies the text overflow option. The options include:

    • LabelOverflow.Ellipse: Trims the text if it exceeds the defined margins.
    • TextOverflow.Clip: Shows the text as it is.
      The default value is Ellipse.

    TextStyle

    Gets or sets an instance of ChartLegendTextStyle that specifies the text style of the legend.

    Declaration
    public ChartLegendTextStyle TextStyle { get; set; }
    Property Value
    Type Description
    ChartLegendTextStyle

    The default value is an instance of ChartLegendTextStyle.

    Remarks

    The legend text font and alignment can be customized using this instance of ChartLegendTextStyle.

    TextWrap

    Gets or sets the text wrap behavior when the individual legend text overflows the legend bounds or MaximumLabelWidth.

    Declaration
    public TextWrap TextWrap { get; set; }
    Property Value
    Type Description
    TextWrap

    One of the TextWrap enumeration values that specify the text wrap option. The default value is Normal.

    Remarks

    This property is applicable only when TextOverflow is set to LabelOverflow.Ellipse.

    ToggleVisibility

    Gets or sets a value indicating whether the series' visibility collapses on the legend click.

    Declaration
    public bool ToggleVisibility { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if the series' visibility collapses on the legend click; otherwise, false. The default value is true.

    Remarks

    This property allows users to toggle the visibility of chart series by clicking on the corresponding legend item, enhancing interactivity and user experience.

    Visible

    Gets or sets a value indicating the visibility of the legend.

    Declaration
    public bool Visible { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if the legend is visible; otherwise, false. The default value is true.

    Remarks

    This property controls the display of the chart legend.

    Width

    Gets or sets the width for the legend.

    Declaration
    public string Width { get; set; }
    Property Value
    Type Description
    System.String

    A string representing the width of the legend. Based on the legend position, the width will be calculated. The default value is null.

    Remarks

    Accepts values in either pixels or percentage.

    Methods

    OnInitialized()

    Declaration
    protected override void OnInitialized()

    Implements

    ILegendBase
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved