# Explicit directed transfer layout · Chord

Preview

![Explicit directed transfer layout](chord-depth-center-light.png)

![Explicit directed transfer layout](chord-depth-center-dark.png)

800 × 520 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](chord-depth-center-light.gallery.csharp.txt) 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 = ChordDepthRecipe.Create("center", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(800, 520)), theme, mode,
    new VisualFrame("Explicit directed transfer layout", "Authored display permutations and connector tension preserve source identities and weights", 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>Explicit display order and ribbon tension leave directed source facts and ordinal paint unchanged.</summary>
public static class ChordDepthRecipe {
    public static Chart Create(string variant = "wide", ThemeMode mode = ThemeMode.Light) {
        var compact = variant.StartsWith("compact", StringComparison.Ordinal);
        var form = compact && variant != "compact" ? variant.Substring("compact-".Length) : variant;
        if (form is not ("wide" or "compact" or "source" or "straight" or "center"))
            throw new ArgumentException("Unknown Chord depth variant.", nameof(variant));
        var source = ChartSeries.CreateChord(new ChartSeriesId("service-transfers"), "Transfers", new[] {
            new ChartNode("api", "API"), new ChartNode("web", "Web"), new ChartNode("ops", "Operations"),
            new ChartNode("data", "Data"), new ChartNode("idle", "Standby")
        }, new[] {
            new ChartFlowLink("api-data", "api", "data", 12, 30),
            new ChartFlowLink("api-priority", "api", "data", 4, -10),
            new ChartFlowLink("web-ops", "web", "ops", 9, 15),
            new ChartFlowLink("ops-web", "ops", "web", 3, 5),
            new ChartFlowLink("data-self", "data", "data", 2, 0),
            new ChartFlowLink("zero", "ops", "api", 0, null)
        });
        var chart = Chart.Create().AddSeries(source).Title("Directed service transfers")
            .Size(compact ? 390 : 800, compact ? 460 : 520).Legend(false)
            .Theme(VisualTheme.Graphite()).ThemeMode(mode);
        source.FlowStyle("api-priority", new ChartFlowStyle(stroke: ChartColor.FromHex("#A56421"),
            outlineStroke: new ChartStrokeStyle(width: 2, dash: new[] { 5d, 3d }), strokeDashOffset: 1.5));
        chart.Chord(options => {
            options.LabelContent = ChartChordLabelContent.LabelAndTotals;
            if (form != "source") {
                options.Ordering = new ChartChordOrdering(new[] { "api", "data", "web", "ops", "idle" },
                    new[] { "api-priority", "api-data", "web-ops", "ops-web", "data-self", "zero" },
                    new[] { "api-data", "data-self", "api-priority", "ops-web", "web-ops", "zero" });
                options.RibbonTension = form == "straight" ? 0 : form == "center" ? 1 : .55;
            }
        });
        return chart;
    }
}
```

```
#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 = ChordDepthRecipe.Create("center", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(800, 520)), theme, mode,
    new VisualFrame("Explicit directed transfer layout", "Authored display permutations and connector tension preserve source identities and weights", 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>Explicit display order and ribbon tension leave directed source facts and ordinal paint unchanged.</summary>
public static class ChordDepthRecipe {
    public static Chart Create(string variant = "wide", ThemeMode mode = ThemeMode.Light) {
        var compact = variant.StartsWith("compact", StringComparison.Ordinal);
        var form = compact && variant != "compact" ? variant.Substring("compact-".Length) : variant;
        if (form is not ("wide" or "compact" or "source" or "straight" or "center"))
            throw new ArgumentException("Unknown Chord depth variant.", nameof(variant));
        var source = ChartSeries.CreateChord(new ChartSeriesId("service-transfers"), "Transfers", new[] {
            new ChartNode("api", "API"), new ChartNode("web", "Web"), new ChartNode("ops", "Operations"),
            new ChartNode("data", "Data"), new ChartNode("idle", "Standby")
        }, new[] {
            new ChartFlowLink("api-data", "api", "data", 12, 30),
            new ChartFlowLink("api-priority", "api", "data", 4, -10),
            new ChartFlowLink("web-ops", "web", "ops", 9, 15),
            new ChartFlowLink("ops-web", "ops", "web", 3, 5),
            new ChartFlowLink("data-self", "data", "data", 2, 0),
            new ChartFlowLink("zero", "ops", "api", 0, null)
        });
        var chart = Chart.Create().AddSeries(source).Title("Directed service transfers")
            .Size(compact ? 390 : 800, compact ? 460 : 520).Legend(false)
            .Theme(VisualTheme.Graphite()).ThemeMode(mode);
        source.FlowStyle("api-priority", new ChartFlowStyle(stroke: ChartColor.FromHex("#A56421"),
            outlineStroke: new ChartStrokeStyle(width: 2, dash: new[] { 5d, 3d }), strokeDashOffset: 1.5));
        chart.Chord(options => {
            options.LabelContent = ChartChordLabelContent.LabelAndTotals;
            if (form != "source") {
                options.Ordering = new ChartChordOrdering(new[] { "api", "data", "web", "ops", "idle" },
                    new[] { "api-priority", "api-data", "web-ops", "ops-web", "data-self", "zero" },
                    new[] { "api-data", "data-self", "api-priority", "ops-web", "web-ops", "zero" });
                options.RibbonTension = form == "straight" ? 0 : form == "center" ? 1 : .55;
            }
        });
        return chart;
    }
}
```

<!-- PowerForge markdown artifact sha256:E86A0BC120BE4DE09134DC438F9D95F651E077FE032A544CEE2350331DCFE6B4 -->
