Back to Devexpress

HeatmapAxis.CustomLabelItemsSource Property

wpf-devexpress-dot-xpf-dot-charts-dot-heatmap-dot-heatmapaxis-99597ea0.md

latest5.0 KB
Original Source

HeatmapAxis.CustomLabelItemsSource Property

Gets or sets the collection of View Model objects that is used to create custom labels.

Namespace : DevExpress.Xpf.Charts.Heatmap

Assembly : DevExpress.Xpf.Charts.v25.2.dll

NuGet Package : DevExpress.Wpf.Charts

Declaration

csharp
public IEnumerable CustomLabelItemsSource { get; set; }
vb
Public Property CustomLabelItemsSource As IEnumerable

Property Value

TypeDescription
IEnumerable

A collection that is used to generate custom labels.

|

Remarks

To generate custom axis labels from a ViewModel, bind an axis’s CustomLabelItemsSource to a collection of objects that contain custom axis label settings. Use the CustomLabelItemTemplate or CustomLabelItemTemplateSelector property to specify how to display custom axis labels.

Example

The following example generates custom labels for an x-axis:

xaml
<dxh:HeatmapControl>
    <dxh:HeatmapControl.DataContext>
        <local:MatrixHeatmapViewModel/>
    </dxh:HeatmapControl.DataContext>
    <!--...-->
    <dxh:HeatmapControl.AxisX>
        <dxh:HeatmapAxis LabelVisibilityMode="AutoGeneratedAndCustom" 
                         CustomLabelItemsSource="{Binding CustomLabels}">
            <dxh:HeatmapAxis.CustomLabelItemTemplate>
                <DataTemplate>
                    <dxc:CustomAxisLabel Value="{Binding AxisValue}" 
                                         Content="{Binding Text}"/>
                </DataTemplate>
            </dxh:HeatmapAxis.CustomLabelItemTemplate>
        </dxh:HeatmapAxis>
    </dxh:HeatmapControl.AxisX>
</dxh:HeatmapControl>
csharp
using System.Collections.Generic;
using System.Windows;
namespace HeatmapChart {
    public class MatrixHeatmapViewModel {
        public string[] XArguments { get; set; }
        public string[] YArguments { get; set; }
        public double[,] Values { get; set; }
        public List<CustomLabel> CustomLabels { get; set; }
        public MatrixHeatmapViewModel() {
            XArguments = new string[] { "March", "April", "May", "June", "July" };
            YArguments = new string[] { "Accessories", "Bikes", "Clothing", "Components" };
            Values = new double[,] {
               { 214.3, 530.1, 630.2, 854.4, 313.4 },
               { 321.3, 514.4, 281.3, 533.4, 541.9 },
               { 604.3, 429.1, 632.6, 438.4, 265.4 },
               { 485.3, 544.7, 740.3, 661.4, 516.6 }
            };
            CustomLabels = new List<CustomLabel> {
                new CustomLabel{ AxisValue = "April", Text = "April (04/30)" },
                new CustomLabel{ AxisValue = "May", Text = "May (05/31)" },
            };
        }
    }
    public class CustomLabel {
        public string AxisValue { get; set; }
        public string Text { get; set; }
    }
}
vb
Imports System.Collections.Generic

Namespace HeatmapChart
    Public Class MatrixHeatmapViewModel
        Public Property XArguments As String()
        Public Property YArguments As String()
        Public Property Values As Double(,)
        Public Property CustomLabels As List(Of CustomLabel)

        Public Sub New()
            XArguments = New String() {"March", "April", "May", "June", "July"}
            YArguments = New String() {"Accessories", "Bikes", "Clothing", "Components"}
            Values = New Double(,) {
            {214.3, 530.1, 630.2, 854.4, 313.4},
            {321.3, 514.4, 281.3, 533.4, 541.9},
            {604.3, 429.1, 632.6, 438.4, 265.4},
            {485.3, 544.7, 740.3, 661.4, 516.6}}
            CustomLabels = New List(Of CustomLabel) From {
                New CustomLabel With {
                    .AxisValue = "April",
                    .Text = "April (04/30)"
                },
                New CustomLabel With {
                    .AxisValue = "May",
                    .Text = "May (05/31)"
                }
            }
        End Sub
    End Class

    Public Class CustomLabel
        Public Property AxisValue As String
        Public Property Text As String
    End Class
End Namespace

See Also

HeatmapAxis Class

HeatmapAxis Members

DevExpress.Xpf.Charts.Heatmap Namespace