← Gallery

Sankey

Requests across processing stages

Explore the example, download the output or use the C# source in your own project.

Preview
Requests across processing stagesChart with 1 data series: Requests.
Requests across processing stages
Requests across processing stagesChart with 1 data series: Requests.
Requests across processing stages
800 × 440 pixels

Create this example

Create a console project, add the ChartForgeX package, and replace Program.cs with this source. Run it to write SVG, PNG and HTML with the default system fonts.

For the same typography as the gallery, download the gallery-font recipe and copy the gallery’s fonts directory beside your program.

#region Setup
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using ChartForgeX;
using ChartForgeX.Core;
using ChartForgeX.Primitives;
using ChartForgeX.Rendering;
using ChartForgeX.Themes;
using ChartForgeX.Topology;
using ChartForgeX.Typography;
using ChartForgeX.VisualArtifacts;
using ChartForgeX.VisualBlocks;

var mode = ThemeMode.Light;
var theme = VisualTheme.Graphite();
var model = SankeyPaintRecipe.Create("gradient-colors", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(800, 440)), theme, mode,
    new VisualFrame("Requests across processing stages", "", showLegend: null, showSurface: false));
var prepared = model.Prepare(context);
File.WriteAllText("visual.svg", prepared.ToSvg());
File.WriteAllBytes("visual.png", prepared.ToPng());
File.WriteAllText("visual.html", prepared.ToArtifact("example", VisualArtifactKind.Chart).ToHtmlPage());
#endregion

/// <summary>Endpoint gradients and outlined labels use the same native Sankey scene in SVG and PNG.</summary>
public static class SankeyPaintRecipe {
    public static Chart Create(string variant = "gradient-colors", ThemeMode mode = ThemeMode.Light) {
        var chart = Chart.Create().AddSankey("Requests", new[] {
            new ChartNode("received", "Received"), new ChartNode("review", "Review"), new ChartNode("ready", "Ready")
        }, new[] {
            new ChartFlowLink("standard", "received", "review", 60),
            new ChartFlowLink("priority", "received", "review", 20),
            new ChartFlowLink("delivered", "review", "ready", 80)
        }).Sankey(options => {
            options.FlowColorMode = ChartSankeyFlowColorMode.Gradient;
            options.LabelStyle = ChartSankeyLabelStyle.Outlined;
            options.RibbonOpacity = .6; options.NodeWidth = 16;
        }).ValueFormat(ChartValueFormat.Number("0", CultureInfo.InvariantCulture));
        chart.Series[0].PointColor(0, ChartColor.FromHex("#2864B4"))
            .PointColor(1, ChartColor.FromHex("#BB6428")).PointColor(2, ChartColor.FromHex("#279473"))
            .FlowStyle("priority", new ChartFlowStyle(fill: ChartColor.FromHex("#7954AA"), fillOpacity: .75));
        return chart;
    }
}
#region Setup
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using ChartForgeX;
using ChartForgeX.Core;
using ChartForgeX.Primitives;
using ChartForgeX.Rendering;
using ChartForgeX.Themes;
using ChartForgeX.Topology;
using ChartForgeX.Typography;
using ChartForgeX.VisualArtifacts;
using ChartForgeX.VisualBlocks;

var mode = ThemeMode.Dark;
var theme = VisualTheme.Graphite();
var model = SankeyPaintRecipe.Create("gradient-colors", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(800, 440)), theme, mode,
    new VisualFrame("Requests across processing stages", "", showLegend: null, showSurface: false));
var prepared = model.Prepare(context);
File.WriteAllText("visual.svg", prepared.ToSvg());
File.WriteAllBytes("visual.png", prepared.ToPng());
File.WriteAllText("visual.html", prepared.ToArtifact("example", VisualArtifactKind.Chart).ToHtmlPage());
#endregion

/// <summary>Endpoint gradients and outlined labels use the same native Sankey scene in SVG and PNG.</summary>
public static class SankeyPaintRecipe {
    public static Chart Create(string variant = "gradient-colors", ThemeMode mode = ThemeMode.Light) {
        var chart = Chart.Create().AddSankey("Requests", new[] {
            new ChartNode("received", "Received"), new ChartNode("review", "Review"), new ChartNode("ready", "Ready")
        }, new[] {
            new ChartFlowLink("standard", "received", "review", 60),
            new ChartFlowLink("priority", "received", "review", 20),
            new ChartFlowLink("delivered", "review", "ready", 80)
        }).Sankey(options => {
            options.FlowColorMode = ChartSankeyFlowColorMode.Gradient;
            options.LabelStyle = ChartSankeyLabelStyle.Outlined;
            options.RibbonOpacity = .6; options.NodeWidth = 16;
        }).ValueFormat(ChartValueFormat.Number("0", CultureInfo.InvariantCulture));
        chart.Series[0].PointColor(0, ChartColor.FromHex("#2864B4"))
            .PointColor(1, ChartColor.FromHex("#BB6428")).PointColor(2, ChartColor.FromHex("#279473"))
            .FlowStyle("priority", new ChartFlowStyle(fill: ChartColor.FromHex("#7954AA"), fillOpacity: .75));
        return chart;
    }
}