← 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 stagesExplore the data, then download the chartReceived 100Automatic 72Manual 28Completed 85Review 15
Requests across processing stages
Requests across processing stagesChart with 1 data series: Requests.Requests across processing stagesExplore the data, then download the chartReceived 100Automatic 72Manual 28Completed 85Review 15
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.

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
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 = VisualThemeMode.Light;
var theme = VisualTheme.Graphite();
var model = SankeyRecipe.Create("wide", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(800, 440)), theme, mode,
    new VisualFrame("Requests across processing stages", "Explore the data, then download the chart", 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());

/// <summary>Weighted requests flow through automatic and manual processing.</summary>
public static class SankeyRecipe {
    public static Chart Create(string variant = "wide", VisualThemeMode mode = VisualThemeMode.Light) {
        var requests = ChartSeries.CreateSankey(new ChartSeriesId("requests"), "Requests", new[] {
            new ChartNode("received", "Received"), new ChartNode("automatic", "Automatic"), new ChartNode("manual", "Manual"),
            new ChartNode("completed", "Completed"), new ChartNode("review", "Review")
        }, new[] {
            new ChartFlowLink("received-automatic", "received", "automatic", 72), new ChartFlowLink("received-manual", "received", "manual", 28),
            new ChartFlowLink("automatic-completed", "automatic", "completed", 65), new ChartFlowLink("automatic-review", "automatic", "review", 7),
            new ChartFlowLink("manual-completed", "manual", "completed", 20), new ChartFlowLink("manual-review", "manual", "review", 8)
        });
        if (variant == "sparse") requests.ReplaceFlowData(new[] {
            new ChartNode("received", "Received"), new ChartNode("completed", "Completed"), new ChartNode("review", "Review")
        }, new[] {
            new ChartFlowLink("received-completed", "received", "completed", 85),
            new ChartFlowLink("received-review", "received", "review", 15)
        });
        return Chart.Create().AddSeries(requests).WithValueFormat(ChartValueFormat.Number("0.##", CultureInfo.InvariantCulture));
    }
}
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
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 = VisualThemeMode.Dark;
var theme = VisualTheme.Graphite();
var model = SankeyRecipe.Create("wide", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(800, 440)), theme, mode,
    new VisualFrame("Requests across processing stages", "Explore the data, then download the chart", 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());

/// <summary>Weighted requests flow through automatic and manual processing.</summary>
public static class SankeyRecipe {
    public static Chart Create(string variant = "wide", VisualThemeMode mode = VisualThemeMode.Light) {
        var requests = ChartSeries.CreateSankey(new ChartSeriesId("requests"), "Requests", new[] {
            new ChartNode("received", "Received"), new ChartNode("automatic", "Automatic"), new ChartNode("manual", "Manual"),
            new ChartNode("completed", "Completed"), new ChartNode("review", "Review")
        }, new[] {
            new ChartFlowLink("received-automatic", "received", "automatic", 72), new ChartFlowLink("received-manual", "received", "manual", 28),
            new ChartFlowLink("automatic-completed", "automatic", "completed", 65), new ChartFlowLink("automatic-review", "automatic", "review", 7),
            new ChartFlowLink("manual-completed", "manual", "completed", 20), new ChartFlowLink("manual-review", "manual", "review", 8)
        });
        if (variant == "sparse") requests.ReplaceFlowData(new[] {
            new ChartNode("received", "Received"), new ChartNode("completed", "Completed"), new ChartNode("review", "Review")
        }, new[] {
            new ChartFlowLink("received-completed", "received", "completed", 85),
            new ChartFlowLink("received-review", "received", "review", 15)
        });
        return Chart.Create().AddSeries(requests).WithValueFormat(ChartValueFormat.Number("0.##", CultureInfo.InvariantCulture));
    }
}