Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

HeatmapDataSourceAdapter.XArgumentComparer Property

Gets or sets a comparer that is used to specify custom sort order for x-arguments.

Namespace: DevExpress.Xpf.Charts.Heatmap

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

NuGet Package: DevExpress.Wpf.Charts

#Declaration

[Browsable(false)]
public IComparer XArgumentComparer { get; set; }

#Property Value

Type Description
IComparer

An object that implements the IComparer interface.

#Remarks

The following example sorts heatmap x-arguments:

Custom sort is applied to x-arguments. X-arguments are shown in default order.
Custom sorting Default sorting
<dx:ThemedWindow
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:dxh="http://schemas.devexpress.com/winfx/2008/xaml/heatmap" 
    x:Class="HeatmapComparers.MainWindow"
    xmlns:local="clr-namespace:HeatmapComparers"
    Title="MainWindow" Height="800" Width="1000">
    <Grid>
        <dxh:HeatmapControl Width="360" Height="360">
            <dxh:HeatmapControl.DataContext>
                <local:MatrixHeatmapViewModel/>
            </dxh:HeatmapControl.DataContext>
            <dxh:HeatmapDataSourceAdapter DataSource="{Binding DataPoints}" 
                                          XArgumentDataMember="XArgument" 
                                          YArgumentDataMember="YArgument" 
                                          ColorDataMember="Value">
                <dxh:HeatmapDataSourceAdapter.XArgumentComparer>
                    <local:NumberComparer/>
                </dxh:HeatmapDataSourceAdapter.XArgumentComparer>
            </dxh:HeatmapDataSourceAdapter>
            <dxh:HeatmapControl.ColorProvider>
                <dxh:HeatmapObjectColorProvider/>
            </dxh:HeatmapControl.ColorProvider>
        </dxh:HeatmapControl>
    </Grid>
</dx:ThemedWindow>
using DevExpress.Xpf.Core;
using System;
using System.Collections;
using System.Collections.Generic;
namespace HeatmapComparers {
    public partial class MainWindow : ThemedWindow {
        public MainWindow() {
            InitializeComponent();
        }
    }
    class NumberComparer : IComparer {
        public int Compare(object x, object y) {
            int iX = NumberConverter.ToInt(x);
            int iY = NumberConverter.ToInt(y);
            return iX - iY;
        }
    }
    class NumberConverter {
        public static int ToInt(object o) {
            string stringNumber = o as string;
            if (stringNumber == null) return -1;
            int number;
            if (Int32.TryParse(stringNumber, out number))
                return number;
            switch (stringNumber.ToLower()) {
                case "one": return 1;
                case "two": return 2;
                case "three": return 3;
            }
            return number;
        }
    }
    public class MatrixHeatmapViewModel {
        public List<DataPoint> DataPoints { get; set; }
        public MatrixHeatmapViewModel() {
            DataPoints = new List<DataPoint> {
                new DataPoint("Two",   "A", -454543),
                new DataPoint("Three", "A", -522512),
                new DataPoint("One",   "A", -4569871),
                new DataPoint("Two",   "B", -8454),
                new DataPoint("Three", "B", -455621),
                new DataPoint("One",   "B", -52485),
                new DataPoint("Two",   "C", -218785),
                new DataPoint("One",   "C", -12544),
                new DataPoint("Three", "C", -544521),
            };
        }
    }
    public class DataPoint {
        public string XArgument { get; set; }
        public string YArgument { get; set; }
        public double Value { get; set; }
        public DataPoint(string x, string y, double value) {
            this.XArgument = x;
            this.YArgument = y;
            this.Value = value;
        }        
    }
}
See Also