Back to Devexpress

HeatmapLabel.Pattern Property

corelibraries-devexpress-dot-xtracharts-dot-heatmap-dot-heatmaplabel-0c788c57.md

latest10.4 KB
Original Source

HeatmapLabel.Pattern Property

Gets or sets a string pattern that formats heatmap label text.

Namespace : DevExpress.XtraCharts.Heatmap

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
[XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)]
public string Pattern { get; set; }
vb
<XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)>
Public Property Pattern As String

Property Value

TypeDescription
String

A format string.

|

Remarks

Patterns can comprise plain text and placeholders with format specifiers. The following table lists available placeholders:

PlaceholderDescription
{X}Displays a heatmap cell x-argument.
{Y}Displays a heatmap cell y-argument.
{V}Displays a heatmap cell value.

When the Heatmap control is bound to data, the pattern can contain data field names in addition to placeholders. For example, you can use the "{CustomText}" pattern for data items similar to the following:

xml
<Item>
  <Country>China</Country>
  <Product>Computer</Product>
  <Value>-151.9</Value>
  <CustomText>Test</CustomText>
</Item>

The following code shows how to use custom placeholders to format heatmap labels:

csharp
heatmap.Label.Pattern = "{CustomText}";
vb
heatmap.Label.Pattern = "{CustomText}"

Example

The following example shows how to configure heatmap cell label settings such as format, font, color, and so on.

Use the HeatmapControl.Label property to access label settings:

csharp
using DevExpress.Drawing;
using DevExpress.XtraCharts;
using DevExpress.XtraCharts.Heatmap;
using System;
using System.Drawing;
using System.Windows.Forms;

namespace HeatmapMatrixAdapterSample {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();

            HeatmapControl heatmap = new HeatmapControl();
            this.Controls.Add(heatmap);

            heatmap.Dock = DockStyle.Fill;

            HeatmapMatrixAdapter dataAdapter = new HeatmapMatrixAdapter();
            dataAdapter.XArguments = new string[] { "North", "South", "West", "East", "Central" };
            dataAdapter.YArguments = new string[] { "Components", "Clothing", "Bikes", "Accessories" };
            dataAdapter.Values = new double[,] {
                { 21.3, 50.1, 63.2, 64.4, 33.4 },
                { 32.3, 54.4, 81.3, 53.4, 54.9 },
                { 60.3, 49.1, 42.6, 48.4, 65.4 },
                { 45.3, 54.7, 70.3, 66.4, 56.6 }
            };
            heatmap.DataAdapter = dataAdapter;
            Palette palette = new Palette("Custom") { Color.White, Color.SkyBlue, Color.DarkBlue };
            RangeColorProvider colorProvider = new RangeColorProvider() { Palette = palette, ApproximateColors = true };
            colorProvider.RangeStops.Add(new Unit(0, UnitType.Percentage));
            colorProvider.RangeStops.Add(new Unit(20, UnitType.Absolute));
            colorProvider.RangeStops.Add(new Unit(40, UnitType.Absolute));
            colorProvider.RangeStops.Add(new Unit(60, UnitType.Absolute));
            colorProvider.RangeStops.Add(new Unit(90, UnitType.Absolute));
            colorProvider.RangeStops.Add(new Unit(1, UnitType.Percentage));
            dataAdapter.ColorProvider = colorProvider;

            HeatmapLabel label = heatmap.Label;
            label.Visible = true;
            label.Pattern = "{V:f0}";
            label.BackColor = Color.White;
            label.Color = Color.Black;
            label.DXFont = new DXFont("SegoeUI", 10);
            label.TextOrientation = HeatmapTextOrientation.Horizontal;
            label.Border.Visibility = DefaultBoolean.True;
            label.Border.Color = Color.DarkGray;
            label.Border.Thickness = 2;
        }
    }
}
vb
Imports DevExpress.Drawing
Imports DevExpress.XtraCharts
Imports DevExpress.XtraCharts.Heatmap
Imports System
Imports System.Drawing
Imports System.Windows.Forms

Namespace HeatmapMatrixAdapterSample
    Public Partial Class Form1
        Inherits Form

        Public Sub New()
            InitializeComponent()
            Dim heatmap As HeatmapControl = New HeatmapControl()
            Me.Controls.Add(heatmap)
            heatmap.Dock = DockStyle.Fill
            Dim dataAdapter As HeatmapMatrixAdapter = New HeatmapMatrixAdapter()
            dataAdapter.XArguments = New String() {"North", "South", "West", "East", "Central"}
            dataAdapter.YArguments = New String() {"Components", "Clothing", "Bikes", "Accessories"}
            dataAdapter.Values = New Double(,) {
            {21.3, 50.1, 63.2, 64.4, 33.4},
            {32.3, 54.4, 81.3, 53.4, 54.9},
            {60.3, 49.1, 42.6, 48.4, 65.4},
            {45.3, 54.7, 70.3, 66.4, 56.6}}
            heatmap.DataAdapter = dataAdapter
            Dim palette As Palette = New Palette("Custom") From {
                System.Drawing.Color.White,
                System.Drawing.Color.SkyBlue,
                System.Drawing.Color.DarkBlue
            }
            Dim colorProvider As RangeColorProvider = New RangeColorProvider() With {
                .Palette = palette,
                .ApproximateColors = True
            }
            colorProvider.RangeStops.Add(New Unit(0, UnitType.Percentage))
            colorProvider.RangeStops.Add(New Unit(20, UnitType.Absolute))
            colorProvider.RangeStops.Add(New Unit(40, UnitType.Absolute))
            colorProvider.RangeStops.Add(New Unit(60, UnitType.Absolute))
            colorProvider.RangeStops.Add(New Unit(90, UnitType.Absolute))
            colorProvider.RangeStops.Add(New Unit(1, UnitType.Percentage))
            dataAdapter.ColorProvider = colorProvider
            Dim label As HeatmapLabel = heatmap.Label
            label.Visible = True
            label.Pattern = "{V:f0}"
            label.BackColor = Color.White
            label.Color = Color.Black
            label.DXFont = New DXFont("SegoeUI", 10)
            label.TextOrientation = HeatmapTextOrientation.Horizontal
            label.Border.Visibility = DefaultBoolean.True
            label.Border.Color = Color.DarkGray
            label.Border.Thickness = 2

        End Sub
    End Class
End Namespace

The following code snippets (auto-collected from DevExpress Examples) contain references to the Pattern property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-heatmap-matrix-data/CS/Form1.cs#L44

csharp
heatmap.Label.Visible = true;
    heatmap.Label.Pattern = "{V}";
}

winforms-heatmap-bind-to-data-source/CS/Form1.cs#L47

csharp
heatmap.Label.DXFont = new DXFont("SegoeUI", 6);
heatmap.Label.Pattern = "{V}";
heatmap.Label.Color = Color.Black;

winforms-dashboard-custom-items-extension/CS/CustomItemExtension/CustomItems/Heatmap/HeatmapItemControlProvider.cs#L66

csharp
dataAdapter.YArgumentDataMember = flatDataSource.GetDisplayTextColumn(dashboardItem.Metadata.Row.UniqueId).Name;
heatmap.Label.Pattern = "{" + flatDataSource.GetDisplayTextColumn(dashboardItem.Metadata.Value.UniqueId).Name + "}";
heatmap.ToolTipTextPattern = string.Format(

winforms-heatmap-matrix-data/VB/Form1.vb#L29

vb
Me.heatmap.Label.Visible = True
    Me.heatmap.Label.Pattern = "{V}"
End Sub

winforms-heatmap-bind-to-data-source/VB/Form1.vb#L32

vb
Me.heatmap.Label.DXFont = New DevExpress.Drawing.DXFont("SegoeUI", 6)
Me.heatmap.Label.Pattern = "{V}"
Me.heatmap.Label.Color = System.Drawing.Color.Black

winforms-dashboard-custom-items-extension/VB/CustomItemExtension/CustomItems/Heatmap/HeatmapItemControlProvider.vb#L75

vb
dataAdapter.YArgumentDataMember = flatDataSource.GetDisplayTextColumn(dashboardItem.Metadata.Row.UniqueId).Name
heatmap.Label.Pattern = "{" & flatDataSource.GetDisplayTextColumn(dashboardItem.Metadata.Value.UniqueId).Name & "}"
heatmap.ToolTipTextPattern = String.Format("X Argument: {{{0}}}" & vbLf & "Y Argument: {{{1}}}" & vbLf & "Value: {{{2}}}", flatDataSource.GetDisplayTextColumn(dashboardItem.Metadata.Column.UniqueId).Name, flatDataSource.GetDisplayTextColumn(dashboardItem.Metadata.Row.UniqueId).Name, flatDataSource.GetDisplayTextColumn(dashboardItem.Metadata.Value.UniqueId).Name)

See Also

HeatmapLabel Class

HeatmapLabel Members

DevExpress.XtraCharts.Heatmap Namespace