← Gallery

Treemap

How work is allocated across teams

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

Preview
How work is allocated across teamsChart with 1 data series: Reconciliation.
How work is allocated across teams
How work is allocated across teamsChart with 1 data series: Reconciliation.
How work is allocated across teams
360 × 360 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 = TreemapCaptionPoliciesRecipe.Create("compact-caption-policies", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(360, 360)), theme, mode,
    new VisualFrame("How work is allocated across teams", "", 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>Opts into bounded caption shrinking and whole-text-element ellipsis while retaining complete source names.</summary>
public static class TreemapCaptionPoliciesRecipe {
    /// <summary>Creates the complete source model; layout and exports use the existing Treemap owner.</summary>
    public static Chart Create(string variant = "caption-policies", ThemeMode mode = ThemeMode.Light) {
        if (variant is not ("caption-policies" or "compact-caption-policies")) throw new ArgumentOutOfRangeException(nameof(variant));
        var chart = Chart.Create().Legend(false).DataLabels().TransparentBackground(false)
            .AddTreemap("Reconciliation", new[] {
                new ChartHierarchyItem("all", "International reconciliation, settlement and regional ownership — complete source caption"),
                new ChartHierarchyItem("processing", "Regional processing reconciliation and settlement allocation", "all", 55),
                new ChartHierarchyItem("regional", "North America processing", "all", 30),
                new ChartHierarchyItem("reserve", "Reserve capacity", "all", 15)
            }).Treemap(options => {
                options.MinimumLabelFontSize = 11;
                options.LabelTrimming = ChartForgeX.Typography.TextTrimming.Ellipsis;
                options.ShowValues = true;
            });
        chart.Series[0].DataLabelStyle(style => style.FontSize(14));
        return chart.ValueFormat(ChartValueFormat.Number("0", System.Globalization.CultureInfo.InvariantCulture));
    }
}
#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 = TreemapCaptionPoliciesRecipe.Create("compact-caption-policies", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(360, 360)), theme, mode,
    new VisualFrame("How work is allocated across teams", "", 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>Opts into bounded caption shrinking and whole-text-element ellipsis while retaining complete source names.</summary>
public static class TreemapCaptionPoliciesRecipe {
    /// <summary>Creates the complete source model; layout and exports use the existing Treemap owner.</summary>
    public static Chart Create(string variant = "caption-policies", ThemeMode mode = ThemeMode.Light) {
        if (variant is not ("caption-policies" or "compact-caption-policies")) throw new ArgumentOutOfRangeException(nameof(variant));
        var chart = Chart.Create().Legend(false).DataLabels().TransparentBackground(false)
            .AddTreemap("Reconciliation", new[] {
                new ChartHierarchyItem("all", "International reconciliation, settlement and regional ownership — complete source caption"),
                new ChartHierarchyItem("processing", "Regional processing reconciliation and settlement allocation", "all", 55),
                new ChartHierarchyItem("regional", "North America processing", "all", 30),
                new ChartHierarchyItem("reserve", "Reserve capacity", "all", 15)
            }).Treemap(options => {
                options.MinimumLabelFontSize = 11;
                options.LabelTrimming = ChartForgeX.Typography.TextTrimming.Ellipsis;
                options.ShowValues = true;
            });
        chart.Series[0].DataLabelStyle(style => style.FontSize(14));
        return chart.ValueFormat(ChartValueFormat.Number("0", System.Globalization.CultureInfo.InvariantCulture));
    }
}