TerraFluent.Chart.Reporting

Sankey Diagram in C#

Draw Sankey flow diagrams in C# with AddSankey, SankeyNode and SankeyLink — proportional ribbons between stages, as self-contained SVG. MIT licensed.

Sankey Flow Diagram

AddSankey() — node-link flow diagram with cubic-bezier links.

E-Commerce Funnel Flow — AddSankey() — visitors to purchase conversion E-Commerce Funnel Flow — AddSankey() — visitors to purchase conversion — Series: Funnel. E-Commerce Funnel Flow AddSankey() — visitors to purchase conversion Visitors Home Page Product Cart Checkout Purchase Bounce Funnel terrafluent.dev terrafluent.dev

When to use a sankey diagram

Reach for it when

  • Quantities flowing and splitting between stages — conversion funnels that branch, energy budgets, traffic sources.
  • Showing where volume is lost, and to what, in one picture.
  • Processes where a stage feeds more than one downstream stage; this is what a funnel cannot do.

Use something else when

  • Flows that do not conserve quantity. A Sankey asserts that what enters a node also leaves it.
  • Many nodes and links — ribbon crossings turn into a tangle past roughly a dozen links.
  • Precise value comparison; label the links when the numbers matter.

Sankey Diagram in C#

Lifted verbatim from the chart types reference, so it compiles against the shipped API. See the API reference for every overload and the exact data types each series method accepts.

using TerraFluent.Chart.Reporting.Models;

string svg = ChartBuilder.Create()
    .Title("Website Conversion Flow")
    .Size(760, 440)
    .AsAnimated()
    .Series(s => s
        .AddSankey("Flow",
            nodes: new[]
            {
                new SankeyNode { Name = "Visitors" },   // 0
                new SankeyNode { Name = "Sign-ups" },   // 1
                new SankeyNode { Name = "Trials" },     // 2
                new SankeyNode { Name = "Paid" },       // 3
                new SankeyNode { Name = "Churned" },    // 4
            },
            links: new[]
            {
                new SankeyLink { From = 0, To = 1, Value = 1000 },
                new SankeyLink { From = 1, To = 2, Value = 620 },
                new SankeyLink { From = 2, To = 3, Value = 240 },
                new SankeyLink { From = 2, To = 4, Value = 380 },
            }))
    .RenderToSvg();

Install

dotnet add package TerraFluent.Chart.Reporting
  • MIT licensed — free for commercial use, no chart limits, no watermarks.
  • Zero dependencies — nothing but the .NET base class library.
  • netstandard2.0 through net10.0 — .NET Framework 4.6.1+, .NET Core 2.0+, and every modern release.
  • Output is one SVG string — embed it in HTML, a PDF, or a Word document.