TreeMapColorizerBase.GetItemColor(TreeMapItem, TreeMapItemGroupInfo) Method
Returns the color for the specified item with the specified tree location.
Namespace: DevExpress.Xpf.TreeMap
Assembly: DevExpress.Xpf.TreeMap.v24.2.dll
NuGet Package: DevExpress.Wpf.TreeMap
#Declaration
public abstract Color? GetItemColor(
TreeMapItem item,
TreeMapItemGroupInfo group
)
#Parameters
Name | Type | Description |
---|---|---|
item | Tree |
A Tree |
group | Tree |
A Tree |
#Returns
Type | Description |
---|---|
Nullable<Color> | A nullable Color value that is the color of the specified item. |
#Example
To implement the custom colorizer, inherit the TreeMapColorizerBase or its descendant class, and override the TreeMapColorizerBase.GetItemColor
method.
Sent as parameters, the TreeMapItem and TreeMapItemGroupInfo objects contain all the required information to colorize items.
Imports DevExpress.Xpf.TreeMap
Imports System.Windows.Media
Namespace CustomColorizerSample
Friend Class CustomColorizer
Inherits TreeMapPaletteColorizerBase
Public Overrides Function GetItemColor(ByVal item As TreeMapItem, ByVal group As TreeMapItemGroupInfo) As Color?
If item.Children.Count = 0 Then
Dim itemColor As Color = Palette(group.ItemIndex Mod Palette.Count)
Dim groupColor As Color = Palette(group.GroupIndex Mod Palette.Count)
Dim proportion As Double = (item.Value - group.MinValue) / (group.MaxValue - group.MinValue)
Return New Color With {.A = 255, .R = CByte(proportion * itemColor.R + (1-proportion)*groupColor.R), .G = CByte(proportion * itemColor.G + (1 - proportion) * groupColor.G), .B = CByte(proportion * itemColor.B + (1 - proportion) * groupColor.B)}
Else
Return Palette(Palette.Count - 1 - group.GroupLevel Mod Palette.Count)
End If
End Function
Protected Overrides Function CreateObject() As TreeMapDependencyObject
Return New CustomColorizer()
End Function
End Class
End Namespace