← Gallery

Slope

Capacity change across teams

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

Preview
Capacity change across teamsChart with 2 data series: Standard, Express.
Capacity change across teams
Capacity change across teamsChart with 2 data series: Standard, Express.
Capacity change across teams
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 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 = SlopeStagesRecipe.Create("stages", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(800, 440)), theme, mode,
    new VisualFrame("Capacity change 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>Compares complete stage observations without inventing values for unrecorded stages.</summary>
public static class SlopeStagesRecipe {
    /// <summary>Creates ordered stage lines, including one explicit disconnected interval, on either physical orientation.</summary>
    public static Chart Create(string variant = "stages", ThemeMode mode = ThemeMode.Light) {
        if (variant is not ("stages" or "compact-stages" or "horizontal-stages" or "compact-horizontal-stages"))
            throw new ArgumentOutOfRangeException(nameof(variant));
        var chart = Chart.Create().Theme(VisualTheme.Graphite()).ThemeMode(mode).XLabels("Received", "Prepared", "Reviewed", "Accepted")
            .Legend(true).DataLabels(false)
            .AddSlope("Standard", new[] { new ChartPoint(1, 28), new ChartPoint(2, 43), new ChartPoint(3, 38), new ChartPoint(4, 64) })
            .AddSlope("Express", new[] { new ChartPoint(1, 52), new ChartPoint(2, 49), new ChartPoint(3, 58, true), new ChartPoint(4, 71) })
            .ValueFormat(ChartValueFormat.Number("0", CultureInfo.InvariantCulture));
        var ids = new[] { "received", "prepared", "reviewed", "accepted" }.Select(id => new ChartObservationId(id)).ToArray();
        foreach (var series in chart.Series) series.ObservationIds(ids);
        if (variant.EndsWith("horizontal-stages", StringComparison.Ordinal)) {
            chart.Options.SlopeOrientation = ChartOrientation.Horizontal;
            chart.XAxis(x => x.Title("Recorded capacity")).YAxis(y => y.Title("Delivery stage"));
        } else chart.XAxis(x => x.Title("Delivery stage")).YAxis(y => y.Title("Recorded 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 = SlopeStagesRecipe.Create("stages", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(800, 440)), theme, mode,
    new VisualFrame("Capacity change 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>Compares complete stage observations without inventing values for unrecorded stages.</summary>
public static class SlopeStagesRecipe {
    /// <summary>Creates ordered stage lines, including one explicit disconnected interval, on either physical orientation.</summary>
    public static Chart Create(string variant = "stages", ThemeMode mode = ThemeMode.Light) {
        if (variant is not ("stages" or "compact-stages" or "horizontal-stages" or "compact-horizontal-stages"))
            throw new ArgumentOutOfRangeException(nameof(variant));
        var chart = Chart.Create().Theme(VisualTheme.Graphite()).ThemeMode(mode).XLabels("Received", "Prepared", "Reviewed", "Accepted")
            .Legend(true).DataLabels(false)
            .AddSlope("Standard", new[] { new ChartPoint(1, 28), new ChartPoint(2, 43), new ChartPoint(3, 38), new ChartPoint(4, 64) })
            .AddSlope("Express", new[] { new ChartPoint(1, 52), new ChartPoint(2, 49), new ChartPoint(3, 58, true), new ChartPoint(4, 71) })
            .ValueFormat(ChartValueFormat.Number("0", CultureInfo.InvariantCulture));
        var ids = new[] { "received", "prepared", "reviewed", "accepted" }.Select(id => new ChartObservationId(id)).ToArray();
        foreach (var series in chart.Series) series.ObservationIds(ids);
        if (variant.EndsWith("horizontal-stages", StringComparison.Ordinal)) {
            chart.Options.SlopeOrientation = ChartOrientation.Horizontal;
            chart.XAxis(x => x.Title("Recorded capacity")).YAxis(y => y.Title("Delivery stage"));
        } else chart.XAxis(x => x.Title("Delivery stage")).YAxis(y => y.Title("Recorded capacity"));
        return chart;
    }
}