Native full and subtree views and complete C# source
TopologyChart owns validated nodes, edges, groups, layout, legends, routes, static HTML, SVG, and raster output. Map application or directory records into stable ids and labels; keep collection and domain rules in the host.
Available layout modes include layered, hub-and-spoke, matrix, dense grouped, geographic, group grid, and manual placement. Hierarchy branches can inherit or override Auto, Standard, Compact, or Vertical layout policy so a dense subtree can compact without changing the rest of the organization chart.
Use TopologyChart.FromData<TNode, TEdge>(...) when the host already owns its records. The mapper preserves input order and rejects duplicate ids or dangling endpoints before rendering.
For large relationship graphs, editing, or runtime graph patches, bridge the model to GraphScene and the HTML graph explorer rather than moving browser state into the core renderer.
Treemap and Sunburst drill-down
Area hierarchies use their native layout. Call chart.PrepareHierarchy(context, new ChartHierarchyView("team-id")) to make an existing item the visible root, or pass null to restore the complete hierarchy. The source items, IDs, authored parents, size/color values and paint overrides remain unchanged. Treemap uses its configured group padding and gap; Sunburst rebases ring depth while preserving authored parent remainders.
The complete native hierarchy program reuses the existing allocation recipe for both families. The figures and downloadable source below show the full and Engineering-root views produced by the native preparation API.
For a connected HTML host, use HtmlInteractiveChartRenderer.PrepareHierarchySection and enable ChartInteractionFeatures.HierarchyNavigation. Group activation, Up one level and Full hierarchy request native re-preparation through connectNative(callback, { basis, axes: null, hierarchy: true }). The callback owns transport and returns the generated section plus a new opaque basis. Bookmarks and SVG/PNG exports follow the accepted view; rejected or stale replies leave it unchanged. The interactivity reference describes the request and lifetime contract.
Use the topology icon-pack guide for reusable stencils and the graph explorer reference for large interactive scenes.
Native full and subtree views
These four views reuse the same source item IDs, parent links and leaf sizes. The complete program prepares each full hierarchy and the Engineering subtree without replacing source data. Download the complete C# program.
// Uses post-3.0.1 hierarchy-view APIs. Build current source or use a later package containing them.
// Exact documentation typography uses Carlito regular/bold installed or registered on the host; other hosts retain normal font fallback.
using System;
using System.IO;
using System.Linq;
using ChartForgeX;
using ChartForgeX.Core;
using ChartForgeX.Primitives;
using ChartForgeX.Rendering;
using ChartForgeX.Themes;
using ChartForgeX.Typography;
var mode = args.Contains("--dark")
? ThemeMode.Dark : ThemeMode.Light;
foreach (var kind in new[] { ChartSeriesKind.Treemap, ChartSeriesKind.Sunburst }) {
var chart = CreateChart(kind, mode);
foreach (var rootId in new string?[] { null, "engineering" }) {
var id = kind.ToString().ToLowerInvariant() + "-" + (rootId ?? "full");
var prepared = chart.PrepareHierarchy(Context(mode), rootId == null ? null : new ChartHierarchyView(rootId));
File.WriteAllText(id + ".svg", prepared.ToSvg(id));
File.WriteAllBytes(id + ".png", prepared.ToPng());
}
}
static Chart CreateChart(ChartSeriesKind kind, ThemeMode mode) {
if (kind is not (ChartSeriesKind.Treemap or ChartSeriesKind.Sunburst)) throw new ArgumentOutOfRangeException(nameof(kind));
// This existing recipe owns every ID, parent and value. Its null group values are valid for both families.
var sunburst = SunburstRecipe.Create("wide", mode).Size(800, 505);
if (kind == ChartSeriesKind.Sunburst) return sunburst.Sunburst(options => {
options.SectorGap = 6;
options.MinimumLabelFontSize = 10;
options.CornerRadius = 4;
});
var source = sunburst.Series[0];
var treemap = ChartSeries.CreateTreemap(source.Id, source.Name, source.HierarchyItems);
treemap.PointColors.AddRange(source.PointColors);
treemap.PointFillPatterns.AddRange(source.PointFillPatterns);
foreach (var state in source.NodeStates) treemap.NodeState(state.Key, state.Value);
return Chart.Create().Size(800, 505).DataLabels().AddSeries(treemap)
.ValueFormat(sunburst.Options.ValueFormat);
}
static VisualRenderContext Context(ThemeMode mode) => new(
new VisualLayoutOptions(new VisualSize(800, 505)), VisualTheme.Graphite(), mode,
new VisualFrame("Team allocation", "Same source hierarchy; full view or Engineering as the visible root", showLegend: false),
FontSpec.FromFamily("Carlito"));
/// <summary>Creates a sunburst showing allocation through a team hierarchy.</summary>
public static class SunburstRecipe {
/// <summary>Creates the source model for a gallery variant without choosing an export backend.</summary>
public static Chart Create(string variant = "wide", ThemeMode mode = ThemeMode.Light) {
if (variant is not ("wide" or "compact" or "sparse" or "options" or "compact-options"
or "authored-total" or "compact-authored-total"))
throw new ArgumentOutOfRangeException(nameof(variant));
var inclusive = variant is "authored-total" or "compact-authored-total";
var configured = inclusive || variant is "options" or "compact-options";
var items = new[] {
new ChartHierarchyItem("all", "All teams", value: configured ? 140 : null, colorValue: configured ? -10 : null),
new ChartHierarchyItem("engineering", "Engineering", "all", configured ? 80 : null, configured ? 12 : null),
new ChartHierarchyItem("operations", "Operations", "all", colorValue: configured ? 0 : null),
new ChartHierarchyItem("platform", "Platform", "engineering", 35, configured ? -4 : null),
new ChartHierarchyItem("engineering-support", "Support", "engineering", 25, configured ? 5 : null),
new ChartHierarchyItem("operations-support", "Support", "operations", 40),
new ChartHierarchyItem("reserve", "Reserve", "operations", 0)
};
var allocation = ChartSeries.CreateSunburst(new ChartSeriesId("allocation-source"), "Allocated work", items);
var chart = Chart.Create().DataLabels().AddSeries(allocation);
if (configured) {
var colors = VisualTheme.Graphite().Resolve(mode);
var low = mode == ThemeMode.Dark ? ChartColor.FromRgb(153, 138, 224) : ChartColor.FromRgb(101, 78, 169);
var high = mode == ThemeMode.Dark ? ChartColor.FromRgb(238, 157, 98) : ChartColor.FromRgb(191, 92, 34);
chart.Sunburst(options => {
options.CornerRadius = 6;
options.SecondaryLabelFormatter = context => context.Item.Id == "all" ? "Allocation" : context.Item.Id == "engineering" ? "Delivery teams"
: context.Item.Id == "operations-support" ? "Shared service" : null;
options.ParentValuePolicy = inclusive ? ChartHierarchyValuePolicy.AuthoredTotal : ChartHierarchyValuePolicy.LeafAggregate;
options.ColorDimension.Name = "Change (%)";
options.ColorScale = ChartColorScale.Diverging(low, colors.Border, high, 0).WithValueRange(-10, 15)
.WithLabels("Decrease", "No change", "Increase").WithNoDataColor(colors.Surface);
});
allocation.NodeState("engineering-support", ChartSeriesState.Warning);
allocation.PointFillPattern(4, ChartFillPattern.DiagonalForward);
}
return chart;
}
}