SunburstPaletteColorizerBase.GetItemBrush(ISunburstSectorInfo) Method
Returns a brush that is applied to the sector.
Namespace: DevExpress.Xpf.TreeMap
Assembly:
DevExpress.Xpf.TreeMap.v24.1.dll
NuGet Package:
DevExpress.Wpf.TreeMap
Declaration
public override Brush GetItemBrush(
ISunburstSectorInfo item
)
Public Overrides Function GetItemBrush(
item As ISunburstSectorInfo
) As Brush
Parameters
Name |
Type |
Description |
item |
DevExpress.Xpf.TreeMap.ISunburstSectorInfo |
Contains information about the Sunburst sector.
|
Returns
Type |
Description |
Brush |
A brush that is applied to the sector.
|
The following code creates and applies a custom colorizer to a Sunburst chart.
<dxtm:SunburstControl>
<dxtm:SunburstControl.Colorizer>
<local:ChemicalElementColorizer />
</dxtm:SunburstControl.Colorizer>
</dxtm:SunburstControl>
public class ChemicalElementColorizer : SunburstColorizerBase {
Dictionary<string, Brush> brushes;
Dictionary<string, Brush> Brushes {
get {
if (brushes == null) {
brushes = new Dictionary<string, Brush>();
Brush sBlockBrush = new SolidColorBrush(Color.FromArgb(255, 216, 103, 159));
sBlockBrush.Freeze();
brushes["S-block"] = sBlockBrush;
Brush pBlockBrush = new SolidColorBrush(Color.FromArgb(255, 234, 202, 39));
pBlockBrush.Freeze();
brushes["P-block"] = pBlockBrush;
Brush dBlockBrush = new SolidColorBrush(Color.FromArgb(255, 102, 156, 220));
dBlockBrush.Freeze();
brushes["D-block"] = dBlockBrush;
Brush fBlockBrush = new SolidColorBrush(Color.FromArgb(255, 126, 171, 54));
fBlockBrush.Freeze();
brushes["F-block"] = fBlockBrush;
Brush lanthanideBrush = new SolidColorBrush(Color.FromArgb(255, 145, 183, 46));
lanthanideBrush.Freeze();
brushes["Lanthanide"] = lanthanideBrush;
Brush actinideBrush = new SolidColorBrush(Color.FromArgb(255, 107, 160, 52));
actinideBrush.Freeze();
brushes["Actinide"] = actinideBrush;
}
return brushes;
}
}
protected override TreeMapDependencyObject CreateObject() {
return new ChemicalElementColorizer();
}
public override Brush GetItemBrush(ISunburstSectorInfo item) {
ChemicalElement element = item.GroupInfo.IsParent ? (ChemicalElement)((IList)item.SourceObject)[0] : (ChemicalElement)item.SourceObject;
string key = element.Block == "F-block" && item.GroupInfo.GroupLevel > 0 ? element.Family : element.Block;
return Brushes[key];
}
}
Public Class ChemicalElementColorizer
Inherits SunburstColorizerBase
Private brushesField As Dictionary(Of String, Brush)
Private ReadOnly Property Brushes As Dictionary(Of String, Brush)
Get
If brushesField Is Nothing Then
brushesField = New Dictionary(Of String, Brush)()
Dim sBlockBrush As Brush = New SolidColorBrush(Color.FromArgb(255, 216, 103, 159))
sBlockBrush.Freeze()
brushesField("S-block") = sBlockBrush
Dim pBlockBrush As Brush = New SolidColorBrush(Color.FromArgb(255, 234, 202, 39))
pBlockBrush.Freeze()
brushesField("P-block") = pBlockBrush
Dim dBlockBrush As Brush = New SolidColorBrush(Color.FromArgb(255, 102, 156, 220))
dBlockBrush.Freeze()
brushesField("D-block") = dBlockBrush
Dim fBlockBrush As Brush = New SolidColorBrush(Color.FromArgb(255, 126, 171, 54))
fBlockBrush.Freeze()
brushesField("F-block") = fBlockBrush
Dim lanthanideBrush As Brush = New SolidColorBrush(Color.FromArgb(255, 145, 183, 46))
lanthanideBrush.Freeze()
brushesField("Lanthanide") = lanthanideBrush
Dim actinideBrush As Brush = New SolidColorBrush(Color.FromArgb(255, 107, 160, 52))
actinideBrush.Freeze()
brushesField("Actinide") = actinideBrush
End If
Return brushesField
End Get
End Property
Protected Overrides Function CreateObject() As TreeMapDependencyObject
Return New ChemicalElementColorizer()
End Function
Public Overrides Function GetItemBrush(ByVal item As ISunburstSectorInfo) As Brush
Dim element As ChemicalElement = If(item.GroupInfo.IsParent, CType(CType(item.SourceObject, IList)(0), ChemicalElement), CType(item.SourceObject, ChemicalElement))
Dim key As String = If(Equals(element.Block, "F-block") AndAlso item.GroupInfo.GroupLevel > 0, element.Family, element.Block)
Return Brushes(key)
End Function
End Class
Run Demo
See Also