Skip to main content
All docs
V25.1
  • TreeMapPaletteColorizerBase.LegendItemPattern Property

    Gets or sets the format pattern that is applied to a treemap legend item’s text.

    Namespace: DevExpress.XtraTreeMap

    Assembly: DevExpress.XtraTreeMap.v25.1.dll

    NuGet Package: DevExpress.TreeMap

    Declaration

    [XtraSerializableProperty]
    public string LegendItemPattern { get; set; }

    Property Value

    Type Description
    String

    A string that formats legend item text.

    Remarks

    Patterns can contain regular text (displayed as is) and value placeholders in braces. To format numeric and date/time values, you can apply format specifiers. Use a colon to separate a placeholder and its format specifier (for example, “{V:f0}”).

    The following table contains the available placeholders:

    Placeholder Description
    {L} Displays the group name.
    {V} Displays the total value of group items.
    {V1} Displays the first value of the range for a TreeMapRangeColorizer.
    {V2} Displays the second value of the range for a TreeMapRangeColorizer.

    Examples

    How to: Format Legend Item Text

    This example shows how to color treemap items based on value ranges and format the legend item text generated for each colorizer range.

    image

    using DevExpress.XtraTreeMap;
    using System;
    using System.Drawing;
    using DevExpress.Drawing;
    using System.Windows.Forms;
    
    namespace TitlesAndLegend {
        public partial class Form1 : Form {
            public Form1() {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e) {
                // Create and configure a TreeMapRangeColorizer.
                TreeMapRangeColorizer colorizer = new TreeMapRangeColorizer() {
                    Palette = Palette.CreatePalette(Color.FromArgb(0xD8, 0x61, 0x0D), Color.FromArgb(0xEF, 0x80, 0x2B),
                                                   Color.FromArgb(0xFF, 0x9C, 0x11), Color.FromArgb(0xFF, 0xBB, 0x32),
                                                   Color.FromArgb(0xFF, 0xCD, 0x7C)),
                    LegendItemPattern = "{V1:f0} .. {V2:f0}"
                };
                colorizer.RangeStops.AddRange(new double[] { 0, 59, 95, 300, 1300, 2500 });
                // Assign the colorizer to the treemap.
                treeMapControl1.Colorizer = colorizer;
    
                // Create a legend.
                ColorListLegend legend = new ColorListLegend();
    
                //Specify the legend title, and the title's color and font.
                legend.Title.Text = "Assets, $B";
                legend.Title.TextColor = Color.Black;
                legend.Title.DXFont = new DXFont("Tahoma", 10);
    
                // Specify the legend alignment and position.
                legend.Direction = LegendDirection.TopToBottom;
                legend.HorizontalAlignment = LegendHorizontalAlignment.RightOutside;
                legend.VerticalAlignment = LegendVerticalAlignment.Top;
    
                // Assign the legend to the treemap.
                treeMapControl1.Legend = legend;
    
            }
        }
    }
    
    See Also