Back to Devexpress

TreeMapPaletteColorizerBase.LegendItemPattern Property

windowsforms-devexpress-dot-xtratreemap-dot-treemappalettecolorizerbase-d7565ad9.md

latest5.7 KB
Original Source

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.2.dll

NuGet Package : DevExpress.TreeMap

Declaration

csharp
[XtraSerializableProperty]
public string LegendItemPattern { get; set; }
vb
<XtraSerializableProperty>
Public Property LegendItemPattern As String

Property Value

TypeDescription
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:

PlaceholderDescription
{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.

csharp
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;

        }
    }
}
vb
Imports DevExpress.XtraTreeMap
Imports System
Imports System.Drawing
Imports DevExpress.Drawing
Imports System.Windows.Forms

Namespace TitlesAndLegend
    Public Partial Class Form1
        Inherits Form

        Public Sub New()
            InitializeComponent()
        End Sub

        Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
            ' Create and configure a TreeMapRangeColorizer.
            Dim colorizer As TreeMapRangeColorizer = New TreeMapRangeColorizer() With {
                .Palette = Palette.CreatePalette(Color.FromArgb(&HD8, &H61, &H0D), Color.FromArgb(&HEF, &H80, &H2B), Color.FromArgb(&HFF, &H9C, &H11), Color.FromArgb(&HFF, &HBB, &H32), Color.FromArgb(&HFF, &HCD, &H7C)),
                .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.
            Dim legend As ColorListLegend = 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
        End Sub
    End Class
End Namespace

See Also

TreeMapPaletteColorizerBase Class

TreeMapPaletteColorizerBase Members

DevExpress.XtraTreeMap Namespace