# Service capacity before and after · Dumbbell

Preview

![Service capacity before and after](family-dumbbell-horizontal-light.png)

![Service capacity before and after](family-dumbbell-horizontal-dark.png)

800 × 440 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](family-dumbbell-horizontal-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 = DumbbellEndpointRecipe.Create("horizontal", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(800, 440)), theme, mode,
    new VisualFrame("Service capacity before and after", "Horizontal Start and End glyphs retain both authored capacity values", 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>Compares service capacity with independent Start and End glyphs on either physical orientation.</summary>
public static class DumbbellEndpointRecipe {
    /// <summary>Creates source-ordered pairs; marker presentation never sorts or replaces the two endpoint values.</summary>
    public static Chart Create(string variant = "endpoint-markers", ThemeMode mode = ThemeMode.Light) {
        if (variant is not ("horizontal" or "compact-horizontal" or "endpoint-markers" or "compact-endpoint-markers"))
            throw new ArgumentOutOfRangeException(nameof(variant));
        var colors = VisualTheme.Graphite().Resolve(mode);
        var capacity = ChartSeries.CreateDumbbell(new ChartSeriesId("capacity"), "Start / End capacity", new[] {
            new ChartDumbbell(1, 32, 44), new ChartDumbbell(2, 58, 38), new ChartDumbbell(3, 51, 72),
            new ChartDumbbell(4, 43, 67), new ChartDumbbell(5, 81, 58)
        }).ObservationIds(new[] { "standard", "express", "premium", "bulk", "return" }.Select(id => new ChartObservationId(id)))
            .Dumbbell(options => {
                options.StartMarker.Shape = ChartMarkerShape.Circle; options.StartMarker.Radius = 4;
                options.StartMarker.Fill = colors.Palette[1];
                options.EndMarker.Shape = ChartMarkerShape.Diamond; options.EndMarker.Radius = 8;
                options.EndMarker.Fill = colors.Palette[0]; options.EndMarker.Stroke = colors.Surface; options.EndMarker.StrokeWidth = 1;
            });
        var chart = Chart.Create().XLabels("Standard", "Express", "Premium", "Bulk", "Return")
            .Legend(true).DataLabels(false).AddSeries(capacity)
            .ValueFormat(ChartValueFormat.Number("0", CultureInfo.InvariantCulture));
        if (variant.EndsWith("horizontal", StringComparison.Ordinal)) {
            chart.Options.DumbbellOrientation = ChartOrientation.Horizontal;
            chart.XAxis(x => x.Title("Capacity")).YAxis(y => y.Title("Service"));
        } else chart.XAxis(x => x.Title("Service")).YAxis(y => y.Title("Capacity"));
        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 = DumbbellEndpointRecipe.Create("horizontal", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(800, 440)), theme, mode,
    new VisualFrame("Service capacity before and after", "Horizontal Start and End glyphs retain both authored capacity values", 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>Compares service capacity with independent Start and End glyphs on either physical orientation.</summary>
public static class DumbbellEndpointRecipe {
    /// <summary>Creates source-ordered pairs; marker presentation never sorts or replaces the two endpoint values.</summary>
    public static Chart Create(string variant = "endpoint-markers", ThemeMode mode = ThemeMode.Light) {
        if (variant is not ("horizontal" or "compact-horizontal" or "endpoint-markers" or "compact-endpoint-markers"))
            throw new ArgumentOutOfRangeException(nameof(variant));
        var colors = VisualTheme.Graphite().Resolve(mode);
        var capacity = ChartSeries.CreateDumbbell(new ChartSeriesId("capacity"), "Start / End capacity", new[] {
            new ChartDumbbell(1, 32, 44), new ChartDumbbell(2, 58, 38), new ChartDumbbell(3, 51, 72),
            new ChartDumbbell(4, 43, 67), new ChartDumbbell(5, 81, 58)
        }).ObservationIds(new[] { "standard", "express", "premium", "bulk", "return" }.Select(id => new ChartObservationId(id)))
            .Dumbbell(options => {
                options.StartMarker.Shape = ChartMarkerShape.Circle; options.StartMarker.Radius = 4;
                options.StartMarker.Fill = colors.Palette[1];
                options.EndMarker.Shape = ChartMarkerShape.Diamond; options.EndMarker.Radius = 8;
                options.EndMarker.Fill = colors.Palette[0]; options.EndMarker.Stroke = colors.Surface; options.EndMarker.StrokeWidth = 1;
            });
        var chart = Chart.Create().XLabels("Standard", "Express", "Premium", "Bulk", "Return")
            .Legend(true).DataLabels(false).AddSeries(capacity)
            .ValueFormat(ChartValueFormat.Number("0", CultureInfo.InvariantCulture));
        if (variant.EndsWith("horizontal", StringComparison.Ordinal)) {
            chart.Options.DumbbellOrientation = ChartOrientation.Horizontal;
            chart.XAxis(x => x.Title("Capacity")).YAxis(y => y.Title("Service"));
        } else chart.XAxis(x => x.Title("Service")).YAxis(y => y.Title("Capacity"));
        return chart;
    }
}
```

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