Skip to main content
All docs

SankeyColorizerBase Class

A base class for Sankey colorizers.

Namespace: DevExpress.Xpf.Charts.Sankey

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

NuGet Package: DevExpress.Wpf.Charts


public abstract class SankeyColorizerBase :

The following members return SankeyColorizerBase objects:


To paint links and nodes based on a custom algorithm, create a class derived from the SankeyColorizerBase class. Then, assign an object of this class to the SankeyDiagramControl.Colorizer property.

The following example implements a colorizer that applies random colors to nodes and applies a gradient fill to links.

A custom colorizer is applied to a sankey diagram

    <local:MyColorizer LinkSourceColor="Yellow" LinkTargetColor="Red" />
public class MyColorizer : SankeyColorizerBase {
    readonly Random rand = new Random();
    readonly Dictionary<string, Color> KeyColorPairs = new Dictionary<string, Color>();
    public Color LinkSourceColor { get; set; }
    public Color LinkTargetColor { get; set; }
    public override Color GetLinkSourceColor(SankeyLink link) {
        return LinkSourceColor;
    public override Color GetLinkTargetColor(SankeyLink link) {
        return LinkTargetColor;
    public override Color GetNodeColor(SankeyNode info) {
        if (!KeyColorPairs.TryGetValue((string)info.Tag, out Color nodeColor)) {
            nodeColor = GenerateColor();
            KeyColorPairs.Add((string)info.Tag, nodeColor);
        return nodeColor;
    private Color GenerateColor() {
        return Color.FromRgb((byte)rand.Next(256), (byte)rand.Next(256), (byte)rand.Next(256));
See Also