AxisBase.QualitativeScaleComparer Property
Gets or sets the comparer used to compare deferred-axis qualitative scale values.
Namespace: DevExpress.Xpf.Charts
Assembly:
DevExpress.Xpf.Charts.v24.2.dll
NuGet Package:
DevExpress.Wpf.Charts
Declaration
[Browsable(false)]
public IComparer QualitativeScaleComparer { get; set; }
<Browsable(False)>
Public Property QualitativeScaleComparer As IComparer
Property Value
Example
To implement a custom qualitative scale values sort order, assign an object of a class implementing the IComparer interface to the AxisBase.QualitativeScaleComparer
property.
<dxc:XYDiagram2D.AxisX>
<dxc:AxisX2D>
<dxc:AxisX2D.QualitativeScaleComparer>
<local:NumberComparer/>
</dxc:AxisX2D.QualitativeScaleComparer>
</dxc:AxisX2D>
</dxc:XYDiagram2D.AxisX>
using System;
using System.Collections;
namespace CustomSortOrder {
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;
int number = 0;
if (stringNumber == null) return -1;
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;
}
}
}
Imports System
Imports System.Collections
Namespace CustomSortOrder
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)
Dim number As Integer = 0
If stringNumber Is Nothing Then
Return -1
End If
If Int32.TryParse(stringNumber, number) Then
Return number
End If
Select Case stringNumber.ToLower()
Case "one"
Return 1
Case "two"
Return 2
Case "three"
Return 3
End Select
Return number
End Function
End Class
End Namespace
See Also