All docs
V20.2
20.2
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

ISankeyColorizer Interface

Declares the base functionality for Sankey diagram colorizers.

Namespace: DevExpress.XtraCharts.Sankey

Assembly: DevExpress.XtraCharts.v20.2.dll

Declaration

public interface ISankeyColorizer
Public Interface ISankeyColorizer

The following members accept/return ISankeyColorizer objects:

Remarks

Example

This example implements a custom algorithm that paints diagram nodes and links.

To do this, create a class that implements the ISankeyColorizer interface. Then, assign an object of this class to the Colorizer property.

The following code implements a colorizer that applies random colors to nodes and specifies colors used to apply a gradient fill to links:

private void Form1_Load(object sender, EventArgs e) {
    sankeyDiagramControl1.Colorizer = new MyColorizer {
        LinkSourceColor = Color.Red,
        LinkTargetColor = Color.Yellow
    };

public class MyColorizer : ISankeyColorizer {
    public event EventHandler ColorizerChanged;
    Random rand = new Random();
    Dictionary<string, Color> KeyColorPairs = new Dictionary<string, Color>();
    public Color LinkSourceColor { get; set; }
    public Color LinkTargetColor { get; set; }
    public Color GetLinkSourceColor(SankeyLink link) {
        return LinkSourceColor;
    }
    public Color GetLinkTargetColor(SankeyLink link) {
        return LinkTargetColor;
    }
    public 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.FromArgb(rand.Next(256), rand.Next(256), rand.Next(256));
    }
}
See Also