TerraFluent.Chart.Reporting

Treemap in C#

Render treemaps in C# with AddTreemap — proportional rectangles for part-of-whole with many categories. Self-contained SVG from .NET.

Treemap

AddTreemap() — nested rectangles sized proportionally.

Treemap — Portfolio Allocation — AddTreemap() — rectangles sized by value. Treemap — Portfolio Allocation — AddTreemap() — rectangles sized by value. — Series: Allocation. Categories: US Equities to Cash. Values range from 300 to 3.2k. Treemap — Portfolio Allocation AddTreemap() — rectangles sized by value. US Equities 3.2k EU Equities 1.8k Gov Bonds 1.5k Corp Bonds 1.1k EM Equities 900 Real Estate 700 Commodities 400 Cash 300 US Equities: 3.2k EU Equities: 1.8k Gov Bonds: 1.5k Corp Bonds: 1.1k EM Equities: 900 Real Estate: 700 Commodities: 400 Cash: 300 US Equities EU Equities EM Equities Gov Bonds Corp Bonds Real Estate Commodities Cash terrafluent.dev terrafluent.dev

When to use a treemap

Reach for it when

  • Part-of-whole with too many categories for a pie chart — twenty or more still works.
  • Where relative magnitude across a wide dynamic range should be visible at once.
  • Space-constrained layouts; a treemap fills its rectangle completely.

Use something else when

  • Comparing similarly-sized items. Rectangles of different aspect ratios are hard to compare by area.
  • Negative or zero values, which have no area to draw.
  • Change over time — the layout reshuffles between periods and the reader loses track of items.

Treemap 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.

string svg = ChartBuilder.Create()
    .Title("Portfolio Allocation")
    .Size(700, 420)
    .XAxis("Asset",
        "US Equities","EU Equities","EM Equities",
        "Gov Bonds",  "Corp Bonds",
        "Real Estate","Commodities","Cash")
    .AsAnimated()
    .Series(s => s
        .AddTreemap("Allocation",
            new double[] { 3200, 1800, 900, 1500, 1100, 700, 400, 300 }))
    .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.