Skip to main content
All docs
V24.2

HeatmapDataSourceAdapter.YArgumentComparer Property

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

Namespace: DevExpress.Xpf.Charts.Heatmap

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

NuGet Package: DevExpress.Wpf.Charts

Declaration

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

Property Value

Type Description
IComparer

An object that implements the IComparer interface.

Remarks

The following example sorts heatmap y-arguments:

Custom sort is applied to y-arguments. Y-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.YArgumentComparer>
                    <local:NumberComparer/>
                </dxh:HeatmapDataSourceAdapter.YArgumentComparer>
            </dxh:HeatmapDataSourceAdapter>
            <dxh:HeatmapControl.AxisY>
                <dxh:HeatmapAxis Reverse="True"/>
            </dxh:HeatmapControl.AxisY>
            <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("A", "Two",   -454543),
                new DataPoint("A", "Three", -522512),
                new DataPoint("A", "One",   -4569871),
                new DataPoint("B", "Two",   -8454),
                new DataPoint("B", "Three", -455621),
                new DataPoint("B", "One",   -52485),
                new DataPoint("C", "Two",   -218785),
                new DataPoint("C", "One",   -12544),
                new DataPoint("C", "Three", -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