← Gallery

Bullet

Reviewed work against its targets

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

Preview
Reviewed work against its targetsService completion against target with 8 data series: Regional service 1, Regional service 2, Regional service 3, Regional service 4, Regional service 5, Regional service 6, Regional service 7, Regional service 8.
Reviewed work against its targets
Reviewed work against its targetsService completion against target with 8 data series: Regional service 1, Regional service 2, Regional service 3, Regional service 4, Regional service 5, Regional service 6, Regional service 7, Regional service 8.
Reviewed work against its targets
390 × 300 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 = BulletRecipe.Create("compact-dense", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(390, 300)), theme, mode,
    new VisualFrame("Reviewed work against its targets", "", 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>Regional review rates compared with separate targets and qualitative ranges.</summary>
public static class BulletRecipe {
    /// <summary>Creates one measured value per region, each with its own target and range boundaries.</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 "dense" or "compact-dense"))
            throw new ArgumentOutOfRangeException(nameof(variant));
        if (variant is "dense" or "compact-dense") {
            var values = new[] { 0d, 2611.111, 3722.222, 4833.333, 5944.444, 7055.555, 8166.666, 12345.6789 };
            var chart = Chart.Create().Title("Service completion against target").DataLabels();
            for (var index = 0; index < values.Length; index++) chart.AddBullet("Regional service " + (index + 1), values[index], 9500.125,
                0, 10000, new[] { 4000d, 8000 });
            return chart;
        }
        // Share of each region's October cases reviewed within two working days, against its own target;
        // the bands mark poor and acceptable results for that region.
        var regions = new (string Id, string Name, double Reviewed, double Target, double Poor, double Acceptable)[] {
            ("north", "North", 86, 90, 60, 80), ("south", "South", 74, 85, 55, 75), ("east", "East", 91, 90, 60, 80),
            ("west", "West", 68, 80, 50, 70), ("central", "Central", 79, 85, 55, 75), ("online", "Online", 95, 92, 70, 85)
        };
        var review = Chart.Create().ValueFormat(ChartValueFormat.Number("0'%'", CultureInfo.InvariantCulture));
        foreach (var region in variant == "sparse" ? regions.Take(2) : regions)
            review.AddSeries(ChartSeries.CreateBullet(new ChartSeriesId(region.Id), region.Name, region.Reviewed, region.Target,
                rangeEnds: new[] { region.Poor, region.Acceptable }));
        return review;
    }
}
#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 = BulletRecipe.Create("compact-dense", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(390, 300)), theme, mode,
    new VisualFrame("Reviewed work against its targets", "", 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>Regional review rates compared with separate targets and qualitative ranges.</summary>
public static class BulletRecipe {
    /// <summary>Creates one measured value per region, each with its own target and range boundaries.</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 "dense" or "compact-dense"))
            throw new ArgumentOutOfRangeException(nameof(variant));
        if (variant is "dense" or "compact-dense") {
            var values = new[] { 0d, 2611.111, 3722.222, 4833.333, 5944.444, 7055.555, 8166.666, 12345.6789 };
            var chart = Chart.Create().Title("Service completion against target").DataLabels();
            for (var index = 0; index < values.Length; index++) chart.AddBullet("Regional service " + (index + 1), values[index], 9500.125,
                0, 10000, new[] { 4000d, 8000 });
            return chart;
        }
        // Share of each region's October cases reviewed within two working days, against its own target;
        // the bands mark poor and acceptable results for that region.
        var regions = new (string Id, string Name, double Reviewed, double Target, double Poor, double Acceptable)[] {
            ("north", "North", 86, 90, 60, 80), ("south", "South", 74, 85, 55, 75), ("east", "East", 91, 90, 60, 80),
            ("west", "West", 68, 80, 50, 70), ("central", "Central", 79, 85, 55, 75), ("online", "Online", 95, 92, 70, 85)
        };
        var review = Chart.Create().ValueFormat(ChartValueFormat.Number("0'%'", CultureInfo.InvariantCulture));
        foreach (var region in variant == "sparse" ? regions.Take(2) : regions)
            review.AddSeries(ChartSeries.CreateBullet(new ChartSeriesId(region.Id), region.Name, region.Reviewed, region.Target,
                rangeEnds: new[] { region.Poor, region.Acceptable }));
        return review;
    }
}