menu

MAUI

  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class TreeMapLegendSettings - MAUI API Reference | Syncfusion

    Show / Hide Table of Contents

    Class TreeMapLegendSettings

    Represents settings for customizing the appearance of legend items in the SfTreeMap.

    Inheritance
    System.Object
    TreeMapLegendSettings
    Namespace: Syncfusion.Maui.TreeMap
    Assembly: Syncfusion.Maui.TreeMap.dll
    Syntax
    public class TreeMapLegendSettings : Element, IThemeElement

    Constructors

    TreeMapLegendSettings()

    Initializes a new instance of the TreeMapLegendSettings class.

    Declaration
    public TreeMapLegendSettings()

    Fields

    IconSizeProperty

    Identifies the IconSize dependency property.

    Declaration
    public static readonly BindableProperty IconSizeProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for IconSize dependency property.

    IconTypeProperty

    Identifies the IconType dependency property.

    Declaration
    public static readonly BindableProperty IconTypeProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for IconType dependency property.

    ItemsLayoutProperty

    Identifies the ItemsLayout dependency property.

    Declaration
    public static readonly BindableProperty ItemsLayoutProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for ItemsLayout dependency property.

    ItemTemplateProperty

    Identifies the ItemTemplate dependency property.

    Declaration
    public static readonly BindableProperty ItemTemplateProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for ItemTemplate dependency property.

    PlacementProperty

    Identifies the Placement dependency property.

    Declaration
    public static readonly BindableProperty PlacementProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for Placement dependency property.

    ShowLegendProperty

    Identifies the ShowLegend dependency property.

    Declaration
    public static readonly BindableProperty ShowLegendProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for ShowLegend dependency property.

    SizeProperty

    Identifies the Size dependency property.

    Declaration
    public static readonly BindableProperty SizeProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for Size dependency property.

    TextStyleProperty

    Identifies the TextStyle dependency property.

    Declaration
    public static readonly BindableProperty TextStyleProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for TextStyle dependency property.

    Properties

    IconSize

    Gets or sets the size of the legend icons in the SfTreeMap.

    Declaration
    public Size IconSize { get; set; }
    Property Value
    Type Description
    Microsoft.Maui.Graphics.Size

    The default value of IconSize is new Size(16, 16).

    Remarks

    This property will be applicable to only when the ShowLegend is enabled. The legend item text can be set using the LegendLabel property.

    Examples

    The below examples shows, how to set IconSize property of TreeMapLegendSettings in the SfTreeMap.

    • XAML
    • C#
    • C#
    • C#
    <treemap:SfTreeMap x:Name="treeMap"
                       PrimaryValuePath="EmployeesCount"
                       RangeColorValuePath="EmployeesCount"
                       DataSource="{Binding EmployeeDetails}">
       <treemap:SfTreeMap.BindingContext>
           <local:EmployeeViewModel />
       </treemap:SfTreeMap.BindingContext>
       <treemap:SfTreeMap.LegendSettings>
           <treemap:TreeMapLegendSettings ShowLegend="True"
                                          IconSize="15,15"/>
       </treemap:SfTreeMap.LegendSettings>
       <treemap:SfTreeMap.LeafItemSettings>
           <treemap:TreeMapLeafItemSettings LabelPath="JobDescription"
                                            TextFormatOption="Wrap">
           </treemap:TreeMapLeafItemSettings>
       </treemap:SfTreeMap.LeafItemSettings>
       <treemap:SfTreeMap.LeafItemBrushSettings>
           <treemap:TreeMapRangeBrushSettings>
               <treemap:TreeMapRangeBrushSettings.RangeBrushes>
                   <treemap:TreeMapRangeBrush LegendLabel="1 % Growth" From="1" To="50" Brush="#77D8D8" />
                   <treemap:TreeMapRangeBrush LegendLabel="2 % Growth" From="51" To="100" Brush="#AED960" />
               </treemap:TreeMapRangeBrushSettings.RangeBrushes>
           </treemap:TreeMapRangeBrushSettings>
      </treemap:SfTreeMap.LeafItemBrushSettings>
    </treemap:SfTreeMap>
    public class EmployeeDetails
    {
       public string Category { get; set; }
       public string Country { get; set; }
       public string JobDescription { get; set; }
       public string JobGroup { get; set; }
       public int EmployeesCount { get; set; }
    }
    public class EmployeeViewModel
    {
        public EmployeeViewModel()
        {
           this.EmployeeDetails = new ObservableCollection<EmployeeDetails>()
           {
               new EmployeeDetails() { Category = "Employees", Country = "India", JobDescription = "Technical", JobGroup = "Testers", EmployeesCount = 100 },
               new EmployeeDetails() { Category = "Employees", Country = "India", JobDescription = "HR Executives", EmployeesCount = 30 },
               new EmployeeDetails() { Category = "Employees", Country = "India", JobDescription = "Accounts", EmployeesCount = 40 },
           };
        }
       public ObservableCollection<EmployeeDetails> EmployeeDetails
       {
           get;
           set;
        }
    }
    this.treeMap.LegendSettings = new TreeMapLegendSettings() { IconSize = new Size(15, 15) , ShowLegend = true};
    See Also
    RangeColorValuePath
    LegendLabel
    IconType
    Placement
    ShowLegend
    TextStyle
    Size

    IconType

    Gets or sets the type of icons to be used for the legend in the SfTreeMap.

    Declaration
    public LegendIconType IconType { get; set; }
    Property Value
    Type Description
    LegendIconType

    The default value of IconType is Rectangle.

    Remarks

    This property will be applicable to only when the ShowLegend is enabled. The legend item text can be set using the LegendLabel property.

    Examples

    The below examples shows, how to set IconType property of TreeMapLegendSettings in the SfTreeMap.

    • XAML
    • C#
    • C#
    • C#
    <treemap:SfTreeMap x:Name="treeMap"
                       PrimaryValuePath="EmployeesCount"
                       RangeColorValuePath="EmployeesCount"
                       DataSource="{Binding EmployeeDetails}">
       <treemap:SfTreeMap.BindingContext>
           <local:EmployeeViewModel />
       </treemap:SfTreeMap.BindingContext>
        <treemap:SfTreeMap.LegendSettings>
       <treemap:TreeMapLegendSettings ShowLegend="True"
                                      IconType="Diamond">
        </treemap:TreeMapLegendSettings>
       </treemap:SfTreeMap.LegendSettings>
       <treemap:SfTreeMap.LeafItemSettings>
           <treemap:TreeMapLeafItemSettings LabelPath="JobDescription"
                                            TextFormatOption="Wrap">
           </treemap:TreeMapLeafItemSettings>
       </treemap:SfTreeMap.LeafItemSettings>
       <treemap:SfTreeMap.LeafItemBrushSettings>
           <treemap:TreeMapRangeBrushSettings>
               <treemap:TreeMapRangeBrushSettings.RangeBrushes>
                   <treemap:TreeMapRangeBrush LegendLabel="1 % Growth" From="1" To="50" Brush="#77D8D8"  />
                   <treemap:TreeMapRangeBrush LegendLabel="2 % Growth" From="51" To="100" Brush="#AED960"  />
               </treemap:TreeMapRangeBrushSettings.RangeBrushes>
           </treemap:TreeMapRangeBrushSettings>
      </treemap:SfTreeMap.LeafItemBrushSettings>
    </treemap:SfTreeMap>
    public class EmployeeDetails
    {
       public string Category { get; set; }
       public string Country { get; set; }
       public string JobDescription { get; set; }
       public string JobGroup { get; set; }
       public int EmployeesCount { get; set; }
    }
    public class EmployeeViewModel
    {
        public EmployeeViewModel()
        {
           this.EmployeeDetails = new ObservableCollection<EmployeeDetails>()
           {
               new EmployeeDetails() { Category = "Employees", Country = "India", JobDescription = "Technical", JobGroup = "Testers", EmployeesCount = 100 },
               new EmployeeDetails() { Category = "Employees", Country = "India", JobDescription = "HR Executives", EmployeesCount = 30 },
               new EmployeeDetails() { Category = "Employees", Country = "India", JobDescription = "Accounts", EmployeesCount = 40 },
           };
        }
       public ObservableCollection<EmployeeDetails> EmployeeDetails
       {
           get;
           set;
        }
    }
    this.treeMap.LegendSettings = new TreeMapLegendSettings() { IconType = LegendIconType.Diamond, ShowLegend = true };
    See Also
    RangeColorValuePath
    LegendLabel
    IconSize
    Placement
    ShowLegend
    TextStyle
    Size

    ItemsLayout

    Gets or sets the ItemsLayout of the legend within the SfTreeMap.

    Declaration
    public Layout ItemsLayout { get; set; }
    Property Value
    Type
    Microsoft.Maui.Controls.Layout
    Examples

    The below examples shows, how to set ItemsLayout property of TreeMapLegendSettings in the SfTreeMap.

    • XAML
    • C#
    • C#
    • C#
    <treemap:SfTreeMap x:Name="treeMap"
                       PrimaryValuePath="EmployeesCount"
                       RangeColorValuePath="EmployeesCount"
                       DataSource="{Binding EmployeeDetails}">
       <treemap:SfTreeMap.BindingContext>
           <local:EmployeeViewModel />
       </treemap:SfTreeMap.BindingContext>
       <treemap:SfTreeMap.Resources>
           <FlexLayout x:Key="legendLayout"
                       Padding="10,10,10,10">
           </FlexLayout>
       </treemap:SfTreeMap.Resources>
        <treemap:SfTreeMap.LegendSettings>
       <treemap:TreeMapLegendSettings ShowLegend="True"
                                      ItemsLayout="{StaticResource legendLayout}">
        </treemap:TreeMapLegendSettings>
       </treemap:SfTreeMap.LegendSettings>
       <treemap:SfTreeMap.LeafItemSettings>
           <treemap:TreeMapLeafItemSettings LabelPath="JobDescription"
                                            TextFormatOption="Wrap">
           </treemap:TreeMapLeafItemSettings>
       </treemap:SfTreeMap.LeafItemSettings>
       <treemap:SfTreeMap.LeafItemBrushSettings>
           <treemap:TreeMapRangeBrushSettings>
               <treemap:TreeMapRangeBrushSettings.RangeBrushes>
                   <treemap:TreeMapRangeBrush LegendLabel="1 % Growth" From="1" To="50" Brush="#77D8D8"  />
                   <treemap:TreeMapRangeBrush LegendLabel="2 % Growth" From="51" To="100" Brush="#AED960"  />
               </treemap:TreeMapRangeBrushSettings.RangeBrushes>
           </treemap:TreeMapRangeBrushSettings>
      </treemap:SfTreeMap.LeafItemBrushSettings>
    </treemap:SfTreeMap>
    public class EmployeeDetails
    {
       public string Category { get; set; }
       public string Country { get; set; }
       public string JobDescription { get; set; }
       public string JobGroup { get; set; }
       public int EmployeesCount { get; set; }
    }
    public class EmployeeViewModel
    {
        public EmployeeViewModel()
        {
           this.EmployeeDetails = new ObservableCollection<EmployeeDetails>()
           {
               new EmployeeDetails() { Category = "Employees", Country = "India", JobDescription = "Technical", JobGroup = "Testers", EmployeesCount = 100 },
               new EmployeeDetails() { Category = "Employees", Country = "India", JobDescription = "HR Executives", EmployeesCount = 30 },
               new EmployeeDetails() { Category = "Employees", Country = "India", JobDescription = "Accounts", EmployeesCount = 40 },
           };
        }
       public ObservableCollection<EmployeeDetails> EmployeeDetails
       {
           get;
           set;
        }
    }
    this.treeMap.LegendSettings = new TreeMapLegendSettings() { ShowLegend = true, ItemsLayout = new FlexLayout(){ Padding = 10 } };

    ItemTemplate

    Gets or sets the ItemTemplate of the legend within the SfTreeMap.

    Declaration
    public DataTemplate ItemTemplate { get; set; }
    Property Value
    Type
    Microsoft.Maui.Controls.DataTemplate
    Remarks

    The BindingContext of the ItemTemplate is the LegendItem.

    Examples

    The below examples shows, how to set ItemTemplate property of TreeMapLegendSettings in the SfTreeMap.

    • XAML
    • C#
    • C#
    <treemap:SfTreeMap x:Name="treeMap"
                       PrimaryValuePath="EmployeesCount"
                       RangeColorValuePath="EmployeesCount"
                       DataSource="{Binding EmployeeDetails}">
       <treemap:SfTreeMap.BindingContext>
           <local:EmployeeViewModel />
       </treemap:SfTreeMap.BindingContext>
       <treemap:SfTreeMap.Resources>
           <DataTemplate x:Key="legendTemplate">
            <StackLayout Orientation="Horizontal">
                <Rectangle HeightRequest="12"
                           WidthRequest="12" Margin="3"
                           Background="{Binding IconBrush}"/>
                <Label Text="{Binding Text}"
                       Margin="3"/>
            </StackLayout>
        </DataTemplate>
       </treemap:SfTreeMap.Resources>
        <treemap:SfTreeMap.LegendSettings>
       <treemap:TreeMapLegendSettings ShowLegend="True"
                                      ItemTemplate="{StaticResource legendTemplate}">
        </treemap:TreeMapLegendSettings>
       </treemap:SfTreeMap.LegendSettings>
       <treemap:SfTreeMap.LeafItemSettings>
           <treemap:TreeMapLeafItemSettings LabelPath="JobDescription"
                                            TextFormatOption="Wrap">
           </treemap:TreeMapLeafItemSettings>
       </treemap:SfTreeMap.LeafItemSettings>
       <treemap:SfTreeMap.LeafItemBrushSettings>
           <treemap:TreeMapRangeBrushSettings>
               <treemap:TreeMapRangeBrushSettings.RangeBrushes>
                   <treemap:TreeMapRangeBrush LegendLabel="1 % Growth" From="1" To="50" Brush="#77D8D8"  />
                   <treemap:TreeMapRangeBrush LegendLabel="2 % Growth" From="51" To="100" Brush="#AED960"  />
               </treemap:TreeMapRangeBrushSettings.RangeBrushes>
           </treemap:TreeMapRangeBrushSettings>
      </treemap:SfTreeMap.LeafItemBrushSettings>
    </treemap:SfTreeMap>
    public class EmployeeDetails
    {
       public string Category { get; set; }
       public string Country { get; set; }
       public string JobDescription { get; set; }
       public string JobGroup { get; set; }
       public int EmployeesCount { get; set; }
    }
    public class EmployeeViewModel
    {
        public EmployeeViewModel()
        {
           this.EmployeeDetails = new ObservableCollection<EmployeeDetails>()
           {
               new EmployeeDetails() { Category = "Employees", Country = "India", JobDescription = "Technical", JobGroup = "Testers", EmployeesCount = 100 },
               new EmployeeDetails() { Category = "Employees", Country = "India", JobDescription = "HR Executives", EmployeesCount = 30 },
               new EmployeeDetails() { Category = "Employees", Country = "India", JobDescription = "Accounts", EmployeesCount = 40 },
           };
        }
       public ObservableCollection<EmployeeDetails> EmployeeDetails
       {
           get;
           set;
        }
    }

    Placement

    Gets or sets the placement of the legend with in the SfTreeMap.

    Declaration
    public LegendPlacement Placement { get; set; }
    Property Value
    Type Description
    LegendPlacement

    The default value of Placement is Top.

    Remarks

    This property will be applicable to only when the ShowLegend is enabled. The legend item text can be set using the LegendLabel property.

    Examples

    The below examples shows, how to set Placement property of TreeMapLegendSettings in the SfTreeMap.

    • XAML
    • C#
    • C#
    • C#
    <treemap:SfTreeMap x:Name="treeMap"
                       PrimaryValuePath="EmployeesCount"
                       RangeColorValuePath="EmployeesCount"
                       DataSource="{Binding EmployeeDetails}">
       <treemap:SfTreeMap.BindingContext>
           <local:EmployeeViewModel />
       </treemap:SfTreeMap.BindingContext>
        <treemap:SfTreeMap.LegendSettings>
       <treemap:TreeMapLegendSettings ShowLegend="True"
                                      Placement="Left">
        </treemap:TreeMapLegendSettings>
       </treemap:SfTreeMap.LegendSettings>
       <treemap:SfTreeMap.LeafItemSettings>
           <treemap:TreeMapLeafItemSettings LabelPath="JobDescription"
                                            TextFormatOption="Wrap">
           </treemap:TreeMapLeafItemSettings>
       </treemap:SfTreeMap.LeafItemSettings>
       <treemap:SfTreeMap.LeafItemBrushSettings>
           <treemap:TreeMapRangeBrushSettings>
               <treemap:TreeMapRangeBrushSettings.RangeBrushes>
                   <treemap:TreeMapRangeBrush LegendLabel="1 % Growth" From="1" To="50" Brush="#77D8D8"  />
                   <treemap:TreeMapRangeBrush LegendLabel="2 % Growth" From="51" To="100" Brush="#AED960"  />
               </treemap:TreeMapRangeBrushSettings.RangeBrushes>
           </treemap:TreeMapRangeBrushSettings>
      </treemap:SfTreeMap.LeafItemBrushSettings>
    </treemap:SfTreeMap>
    public class EmployeeDetails
    {
       public string Category { get; set; }
       public string Country { get; set; }
       public string JobDescription { get; set; }
       public string JobGroup { get; set; }
       public int EmployeesCount { get; set; }
    }
    public class EmployeeViewModel
    {
        public EmployeeViewModel()
        {
           this.EmployeeDetails = new ObservableCollection<EmployeeDetails>()
           {
               new EmployeeDetails() { Category = "Employees", Country = "India", JobDescription = "Technical", JobGroup = "Testers", EmployeesCount = 100 },
               new EmployeeDetails() { Category = "Employees", Country = "India", JobDescription = "HR Executives", EmployeesCount = 30 },
               new EmployeeDetails() { Category = "Employees", Country = "India", JobDescription = "Accounts", EmployeesCount = 40 },
           };
        }
       public ObservableCollection<EmployeeDetails> EmployeeDetails
       {
           get;
           set;
        }
    }
    this.treeMap.LegendSettings = new TreeMapLegendSettings() { Placement = LegendPlacement.Left, ShowLegend = true };
    See Also
    RangeColorValuePath
    LegendLabel
    IconSize
    IconType
    ShowLegend
    TextStyle
    Size

    ShowLegend

    Gets or sets a value indicating whether the legend is enabled in the SfTreeMap.

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

    The default value of ShowLegend is false/>.

    Remarks

    true if the legend is enabled; otherwise, false. The legend item text can be set using the LegendLabel property.

    Examples

    The below examples shows, how to set ShowLegend property of TreeMapLegendSettings in the SfTreeMap.

    • XAML
    • C#
    • C#
    • C#
    <treemap:SfTreeMap x:Name="treeMap"
                       PrimaryValuePath="EmployeesCount"
                       RangeColorValuePath="EmployeesCount"
                       DataSource="{Binding EmployeeDetails}">
       <treemap:SfTreeMap.BindingContext>
           <local:EmployeeViewModel />
       </treemap:SfTreeMap.BindingContext>
        <treemap:SfTreeMap.LegendSettings>
       <treemap:TreeMapLegendSettings ShowLegend="True">
        </treemap:TreeMapLegendSettings>
       </treemap:SfTreeMap.LegendSettings>
       <treemap:SfTreeMap.LeafItemSettings>
           <treemap:TreeMapLeafItemSettings LabelPath="JobDescription"
                                            TextFormatOption="Wrap">
           </treemap:TreeMapLeafItemSettings>
       </treemap:SfTreeMap.LeafItemSettings>
       <treemap:SfTreeMap.LeafItemBrushSettings>
           <treemap:TreeMapRangeBrushSettings>
               <treemap:TreeMapRangeBrushSettings.RangeBrushes>
                   <treemap:TreeMapRangeBrush LegendLabel="1 % Growth" From="1" To="50" Brush="#77D8D8"  />
                   <treemap:TreeMapRangeBrush LegendLabel="2 % Growth" From="51" To="100" Brush="#AED960"  />
               </treemap:TreeMapRangeBrushSettings.RangeBrushes>
           </treemap:TreeMapRangeBrushSettings>
      </treemap:SfTreeMap.LeafItemBrushSettings>
    </treemap:SfTreeMap>
    public class EmployeeDetails
    {
       public string Category { get; set; }
       public string Country { get; set; }
       public string JobDescription { get; set; }
       public string JobGroup { get; set; }
       public int EmployeesCount { get; set; }
    }
    public class EmployeeViewModel
    {
        public EmployeeViewModel()
        {
           this.EmployeeDetails = new ObservableCollection<EmployeeDetails>()
           {
               new EmployeeDetails() { Category = "Employees", Country = "India", JobDescription = "Technical", JobGroup = "Testers", EmployeesCount = 100 },
               new EmployeeDetails() { Category = "Employees", Country = "India", JobDescription = "HR Executives", EmployeesCount = 30 },
               new EmployeeDetails() { Category = "Employees", Country = "India", JobDescription = "Accounts", EmployeesCount = 40 },
           };
        }
       public ObservableCollection<EmployeeDetails> EmployeeDetails
       {
           get;
           set;
        }
    }
    this.treeMap.LegendSettings = new TreeMapLegendSettings() { ShowLegend = true };
    See Also
    RangeColorValuePath
    LegendLabel
    IconSize
    IconType
    Placement
    TextStyle
    Size

    Size

    Gets or sets the size of the legend layout in the SfTreeMap.

    Declaration
    public Size Size { get; set; }
    Property Value
    Type Description
    Microsoft.Maui.Graphics.Size

    The default size is calculated based on the legend placement. If the legend is placed at the top or bottom, the default height is set to 40 units, and the width is set to the layout width. If the legend is placed on the left or right side:

    • For Android and iOS platforms, the default width is set to 100 units and the height is set to the layout height.
    • For Windows and MAC platforms, the default width is set to 200 units and the height is set to the layout height.
    Remarks

    This property will be applicable to only when the ShowLegend is enabled. The legend item text can be set using the LegendLabel property.

    Examples

    The below examples shows, how to set Size property of TreeMapLegendSettings in the SfTreeMap.

    • XAML
    • C#
    • C#
    • C#
    <treemap:SfTreeMap x:Name="treeMap"
                       PrimaryValuePath="EmployeesCount"
                       RangeColorValuePath="EmployeesCount"
                       DataSource="{Binding EmployeeDetails}">
       <treemap:SfTreeMap.BindingContext>
           <local:EmployeeViewModel />
       </treemap:SfTreeMap.BindingContext>
        <treemap:SfTreeMap.LegendSettings>
       <treemap:TreeMapLegendSettings ShowLegend="True"
                                      Size="300,100">
        </treemap:TreeMapLegendSettings>
       </treemap:SfTreeMap.LegendSettings>
       <treemap:SfTreeMap.LeafItemSettings>
           <treemap:TreeMapLeafItemSettings LabelPath="JobDescription"
                                            TextFormatOption="Wrap">
           </treemap:TreeMapLeafItemSettings>
       </treemap:SfTreeMap.LeafItemSettings>
       <treemap:SfTreeMap.LeafItemBrushSettings>
           <treemap:TreeMapRangeBrushSettings>
               <treemap:TreeMapRangeBrushSettings.RangeBrushes>
                   <treemap:TreeMapRangeBrush LegendLabel="1 % Growth" From="1" To="50" Brush="#77D8D8"  />
                   <treemap:TreeMapRangeBrush LegendLabel="2 % Growth" From="51" To="100" Brush="#AED960"  />
               </treemap:TreeMapRangeBrushSettings.RangeBrushes>
           </treemap:TreeMapRangeBrushSettings>
      </treemap:SfTreeMap.LeafItemBrushSettings>
    </treemap:SfTreeMap>
    public class EmployeeDetails
    {
       public string Category { get; set; }
       public string Country { get; set; }
       public string JobDescription { get; set; }
       public string JobGroup { get; set; }
       public int EmployeesCount { get; set; }
    }
    public class EmployeeViewModel
    {
        public EmployeeViewModel()
        {
           this.EmployeeDetails = new ObservableCollection<EmployeeDetails>()
           {
               new EmployeeDetails() { Category = "Employees", Country = "India", JobDescription = "Technical", JobGroup = "Testers", EmployeesCount = 100 },
               new EmployeeDetails() { Category = "Employees", Country = "India", JobDescription = "HR Executives", EmployeesCount = 30 },
               new EmployeeDetails() { Category = "Employees", Country = "India", JobDescription = "Accounts", EmployeesCount = 40 },
           };
        }
       public ObservableCollection<EmployeeDetails> EmployeeDetails
       {
           get;
           set;
        }
    }
    this.treeMap.LegendSettings = new TreeMapLegendSettings() { Size = new Size(300, 100), ShowLegend = true };
    See Also
    RangeColorValuePath
    LegendLabel
    IconSize
    IconType
    Placement
    TextStyle
    ShowLegend

    TextStyle

    Gets or sets the style of legend item text, that used to customize the text color, font, font size, font family and font attributes.

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

    The default value of TextColor is Microsoft.Maui.Graphics.Colors.Black, FontSize is 12, FontFamily is null, FontAttributes is Microsoft.Maui.Controls.FontAttributes.None

    Remarks

    This property will be applicable to only when the ShowLegend is enabled. The legend item text can be set using the LegendLabel property.

    Examples

    The below examples shows, how to set TextStyle property of TreeMapLegendSettings in the SfTreeMap.

    • XAML
    • C#
    • C#
    • C#
    <treemap:SfTreeMap x:Name="treeMap"
                       PrimaryValuePath="EmployeesCount"
                       RangeColorValuePath="EmployeesCount"
                       DataSource="{Binding EmployeeDetails}">
       <treemap:SfTreeMap.BindingContext>
           <local:EmployeeViewModel />
       </treemap:SfTreeMap.BindingContext>
       <treemap:SfTreeMap.LegendSettings>
       <treemap:TreeMapLegendSettings ShowLegend="True">
           <treemap:TreeMapLegendSettings.TextStyle>
               <treemap:TreeMapTextStyle TextColor="Orange" FontSize="14" FontAttributes="Italic"/>
           </treemap:TreeMapLegendSettings.TextStyle>
          </treemap:TreeMapLegendSettings>
        </treemap:SfTreeMap.LegendSettings>
       <treemap:SfTreeMap.LeafItemSettings>
           <treemap:TreeMapLeafItemSettings LabelPath="JobDescription"
                                            TextFormatOption="Wrap">
           </treemap:TreeMapLeafItemSettings>
       </treemap:SfTreeMap.LeafItemSettings>
       <treemap:SfTreeMap.LeafItemBrushSettings>
           <treemap:TreeMapRangeBrushSettings>
               <treemap:TreeMapRangeBrushSettings.RangeBrushes>
                   <treemap:TreeMapRangeBrush LegendLabel="1 % Growth" From="1" To="50" Brush="#77D8D8"  />
                   <treemap:TreeMapRangeBrush LegendLabel="2 % Growth" From="51" To="100" Brush="#AED960"  />
               </treemap:TreeMapRangeBrushSettings.RangeBrushes>
           </treemap:TreeMapRangeBrushSettings>
      </treemap:SfTreeMap.LeafItemBrushSettings>
    </treemap:SfTreeMap>
    public class EmployeeDetails
    {
       public string Category { get; set; }
       public string Country { get; set; }
       public string JobDescription { get; set; }
       public string JobGroup { get; set; }
       public int EmployeesCount { get; set; }
    }
    public class EmployeeViewModel
    {
        public EmployeeViewModel()
        {
           this.EmployeeDetails = new ObservableCollection<EmployeeDetails>()
           {
               new EmployeeDetails() { Category = "Employees", Country = "India", JobDescription = "Technical", JobGroup = "Testers", EmployeesCount = 100 },
               new EmployeeDetails() { Category = "Employees", Country = "India", JobDescription = "HR Executives", EmployeesCount = 30 },
               new EmployeeDetails() { Category = "Employees", Country = "India", JobDescription = "Accounts", EmployeesCount = 40 },
           };
        }
       public ObservableCollection<EmployeeDetails> EmployeeDetails
       {
           get;
           set;
        }
    }
    this.treeMap.LegendSettings = new TreeMapLegendSettings() { TextStyle = new TreeMapTextStyle() { TextColor = Colors.Orange, FontSize = 14, FontAttributes = FontAttributes.Italic }, ShowLegend = true };
    See Also
    RangeColorValuePath
    LegendLabel
    IconType
    Placement
    ShowLegend
    IconSize
    Size

    Methods

    OnBindingContextChanged()

    Invokes on the binding context of the view changed.

    Declaration
    protected override void OnBindingContextChanged()
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved