wpf-devexpress-dot-xpf-dot-charts-dot-heatmap-dot-heatmapdatasourceadapter-f7d46adb.md
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.v25.2.dll
NuGet Package : DevExpress.Wpf.Charts
[Browsable(false)]
public IComparer YArgumentComparer { get; set; }
<Browsable(False)>
Public Property YArgumentComparer As IComparer
| Type | Description |
|---|---|
| IComparer |
An object that implements the IComparer interface.
|
The following example sorts heatmap y-arguments:
| Custom sort is applied to y-arguments. | Y-arguments are shown in default order. |
|---|---|
<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;
}
}
}
Imports DevExpress.Xpf.Core
Imports System.Collections
Imports System.Collections.Generic
Namespace HeatmapComparers
Public Partial Class MainWindow
Inherits ThemedWindow
Public Sub New()
InitializeComponent()
End Sub
End Class
Friend Class NumberComparer
Implements IComparer
Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements IComparer.Compare
Dim iX As Integer = NumberConverter.ToInt(x)
Dim iY As Integer = NumberConverter.ToInt(y)
Return iX - iY
End Function
End Class
Friend Class NumberConverter
Public Shared Function ToInt(ByVal o As Object) As Integer
Dim stringNumber As String = TryCast(o, String)
If Equals(stringNumber, Nothing) Then Return -1
Dim number As Integer
If Integer.TryParse(stringNumber, number) Then Return number
Select Case stringNumber.ToLower()
Case "one"
Return 1
Case "two"
Return 2
Case "three"
Return 3
End Select
Return number
End Function
End Class
Public Class MatrixHeatmapViewModel
Public Property DataPoints As List(Of DataPoint)
Public Sub New()
DataPoints = New List(Of DataPoint) From {
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)
}
End Sub
End Class
Public Class DataPoint
Public Property XArgument As String
Public Property YArgument As String
Public Property Value As Double
Public Sub New(ByVal x As String, ByVal y As String, ByVal value As Double)
XArgument = x
YArgument = y
Me.Value = value
End Sub
End Class
End Namespace
See Also
HeatmapDataSourceAdapter Class