← Gallery

Topology

Approve a captured release

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

Preview
Approve a captured releaseThe source table remains part of its graph vertex
Approve a captured release
Approve a captured releaseThe source table remains part of its graph vertex
Approve a captured release
390 × 1000 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 = TopologyTableContentRecipe.Create("compact", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(390, 1000)), theme, mode,
    new VisualFrame("Approve a captured release", "The source table remains part of its graph vertex", showLegend: false, 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.Topology).ToHtmlPage());
#endregion

/// <summary>Authors an ordinary native graph with finite, keyed table content inside its real vertex.</summary>
/// <remarks>The separate UseCase source example exercises parsing; this recipe needs only the Core package.</remarks>
public static class TopologyTableContentRecipe {
    /// <summary>Creates a complete native example in compact/wide and both theme modes.</summary>
    public static TopologyChart Create(string variant = "wide", ThemeMode mode = ThemeMode.Light) {
        if (variant is not ("wide" or "compact")) throw new ArgumentOutOfRangeException(nameof(variant));
        var compact = variant == "compact";
        var chart = TopologyChart.Create().Id("linked-table-content").Title("Approve a captured release")
            .Subtitle("The source table remains part of its graph vertex")
            .Theme(VisualTheme.Graphite()).ThemeMode(mode).Viewport(new TopologyViewport(compact ? 390 : 1000, compact ? 1000 : 680, 24))
            .LayoutMode(TopologyLayoutMode.Layered).LayoutDirection(compact ? TopologyLayoutDirection.TopToBottom : TopologyLayoutDirection.LeftToRight);
        chart.DefaultRenderOptions(new TopologyRenderOptions { IncludeLegend = false, FitContentToViewport = true, WrapNodeLabels = true });
        chart.AddAutoNode("User", "Release coordinator", width: 180, height: 90);
        chart.AddAutoNode("Publish", "Approve release", width: 180, height: 70);
        chart.AddAutoNode("Details", "Details", width: 220, height: 130);
        foreach (var node in chart.Nodes) {
            node.Kind = TopologyNodeKind.Generic; node.ShowStatusBadge = false; node.PreserveDisplayModeSize = true;
            node.DisplayMode = TopologyNodeDisplayMode.Card; node.FitLabelToContent = true;
            node.Shape = node.Id == "User" ? TopologyNodeShape.Actor : node.Id == "Publish" ? TopologyNodeShape.Ellipse : TopologyNodeShape.Rectangle;
        }
        chart.Nodes[0].FitLabelToContent = false;
        // This authored participant keeps its complete caption; wrapping/fitting still uses the shared Actor owner.
        chart.Nodes[0].MaximumLabelCharacters = chart.Nodes[0].Label.Length;
        chart.Nodes[2].TableContent = CreateTable();
        chart.AddEdge("request", "User", "Publish", kind: TopologyEdgeKind.Dependency, direction: VisualLinkDirection.Forward, routing: TopologyEdgeRouting.Straight);
        chart.AddEdge("inspect", "Publish", "Details", kind: TopologyEdgeKind.Dependency, direction: VisualLinkDirection.Forward, routing: TopologyEdgeRouting.Straight);
        chart.Annotations.Add(new TopologyAnnotation("table-note", "Captured source facts stay linked", "Details"));
        return chart;
    }
    /// <summary>Loads a saved native graph, edits a detached keyed value, and returns the ordinary editable owner.</summary>
    public static TopologyChart LoadAndEdit(string json) {
        var loaded = VisualArtifactInterchangeEnvelope.FromJson(json).ToTopologyChart();
        var table = loaded.Nodes.Single(node => node.Id == "Details").TableContent!;
        table.Rows.Single(row => row.Key == "/version").Cells[1].DisplayText = "2.00";
        return loaded;
    }
    /// <summary>Creates keyed source facts; null, false, zero and empty strings remain distinct text/type facts.</summary>
    public static TableArtifact CreateTable() {
        var table = TableArtifact.Create("Details").AddColumn("property", "Property").AddColumn("value", "Value");
        Add("/version", "version", "1.00", "Number"); Add("/active", "active", "false", "Boolean"); Add("/memo", "memo", "", "String");
        Add("/owner/name", "owner.name", "Aster", "String"); Add("/owner/missing", "owner.missing", "null", "Null");
        Add("/tags/0", "tags", "ready", "String"); Add("/tags/1", "", "signed", "String");
        Add("/path~1~0", "path/~", "kept", "String"); Add("/empty", "empty", "[]", "Array");
        return table;
        void Add(string pointer, string key, string text, string kind) {
            table.AddRow(pointer, key, text); var row = table.Rows[table.Rows.Count - 1];
            row.Metadata["mermaid.data.pointer"] = pointer; row.Metadata["mermaid.data.kind"] = kind;
            row.Cells[1].Metadata["mermaid.data.kind"] = kind;
        }
    }
}
#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 = TopologyTableContentRecipe.Create("compact", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(390, 1000)), theme, mode,
    new VisualFrame("Approve a captured release", "The source table remains part of its graph vertex", showLegend: false, 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.Topology).ToHtmlPage());
#endregion

/// <summary>Authors an ordinary native graph with finite, keyed table content inside its real vertex.</summary>
/// <remarks>The separate UseCase source example exercises parsing; this recipe needs only the Core package.</remarks>
public static class TopologyTableContentRecipe {
    /// <summary>Creates a complete native example in compact/wide and both theme modes.</summary>
    public static TopologyChart Create(string variant = "wide", ThemeMode mode = ThemeMode.Light) {
        if (variant is not ("wide" or "compact")) throw new ArgumentOutOfRangeException(nameof(variant));
        var compact = variant == "compact";
        var chart = TopologyChart.Create().Id("linked-table-content").Title("Approve a captured release")
            .Subtitle("The source table remains part of its graph vertex")
            .Theme(VisualTheme.Graphite()).ThemeMode(mode).Viewport(new TopologyViewport(compact ? 390 : 1000, compact ? 1000 : 680, 24))
            .LayoutMode(TopologyLayoutMode.Layered).LayoutDirection(compact ? TopologyLayoutDirection.TopToBottom : TopologyLayoutDirection.LeftToRight);
        chart.DefaultRenderOptions(new TopologyRenderOptions { IncludeLegend = false, FitContentToViewport = true, WrapNodeLabels = true });
        chart.AddAutoNode("User", "Release coordinator", width: 180, height: 90);
        chart.AddAutoNode("Publish", "Approve release", width: 180, height: 70);
        chart.AddAutoNode("Details", "Details", width: 220, height: 130);
        foreach (var node in chart.Nodes) {
            node.Kind = TopologyNodeKind.Generic; node.ShowStatusBadge = false; node.PreserveDisplayModeSize = true;
            node.DisplayMode = TopologyNodeDisplayMode.Card; node.FitLabelToContent = true;
            node.Shape = node.Id == "User" ? TopologyNodeShape.Actor : node.Id == "Publish" ? TopologyNodeShape.Ellipse : TopologyNodeShape.Rectangle;
        }
        chart.Nodes[0].FitLabelToContent = false;
        // This authored participant keeps its complete caption; wrapping/fitting still uses the shared Actor owner.
        chart.Nodes[0].MaximumLabelCharacters = chart.Nodes[0].Label.Length;
        chart.Nodes[2].TableContent = CreateTable();
        chart.AddEdge("request", "User", "Publish", kind: TopologyEdgeKind.Dependency, direction: VisualLinkDirection.Forward, routing: TopologyEdgeRouting.Straight);
        chart.AddEdge("inspect", "Publish", "Details", kind: TopologyEdgeKind.Dependency, direction: VisualLinkDirection.Forward, routing: TopologyEdgeRouting.Straight);
        chart.Annotations.Add(new TopologyAnnotation("table-note", "Captured source facts stay linked", "Details"));
        return chart;
    }
    /// <summary>Loads a saved native graph, edits a detached keyed value, and returns the ordinary editable owner.</summary>
    public static TopologyChart LoadAndEdit(string json) {
        var loaded = VisualArtifactInterchangeEnvelope.FromJson(json).ToTopologyChart();
        var table = loaded.Nodes.Single(node => node.Id == "Details").TableContent!;
        table.Rows.Single(row => row.Key == "/version").Cells[1].DisplayText = "2.00";
        return loaded;
    }
    /// <summary>Creates keyed source facts; null, false, zero and empty strings remain distinct text/type facts.</summary>
    public static TableArtifact CreateTable() {
        var table = TableArtifact.Create("Details").AddColumn("property", "Property").AddColumn("value", "Value");
        Add("/version", "version", "1.00", "Number"); Add("/active", "active", "false", "Boolean"); Add("/memo", "memo", "", "String");
        Add("/owner/name", "owner.name", "Aster", "String"); Add("/owner/missing", "owner.missing", "null", "Null");
        Add("/tags/0", "tags", "ready", "String"); Add("/tags/1", "", "signed", "String");
        Add("/path~1~0", "path/~", "kept", "String"); Add("/empty", "empty", "[]", "Array");
        return table;
        void Add(string pointer, string key, string text, string kind) {
            table.AddRow(pointer, key, text); var row = table.Rows[table.Rows.Count - 1];
            row.Metadata["mermaid.data.pointer"] = pointer; row.Metadata["mermaid.data.kind"] = kind;
            row.Cells[1].Metadata["mermaid.data.kind"] = kind;
        }
    }
}