← Gallery

Bullet

Independent operating measurements

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

Preview
Independent operating measurementsIndependent operating measurements with 2 data series: Capacity, Queue.
Independent operating measurements
Independent operating measurementsIndependent operating measurements with 2 data series: Capacity, Queue.
Independent operating measurements
390 × 218 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 = IndependentBulletRecipe.Create("compact", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(390, 218)), theme, mode,
    new VisualFrame("Independent operating measurements", "Separate domains and source units share horizontal or vertical tracks", 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>Different measurement units retain independent domains, captions and targets in horizontal or vertical bullet tracks.</summary>
public static class IndependentBulletRecipe {
    public static Chart Create(string variant = "wide", ThemeMode mode = ThemeMode.Light) {
        if (variant is not ("wide" or "compact" or "vertical" or "compact-vertical")) throw new ArgumentOutOfRangeException(nameof(variant));
        var compact = variant.StartsWith("compact", StringComparison.Ordinal); var vertical = variant.EndsWith("vertical", StringComparison.Ordinal);
        var load = ChartSeries.CreateBullet(new ChartSeriesId("load"), "Capacity", new ChartBulletValue(.72, .8, 0, 1, new[] { .5, .8 }))
            .ObservationId(0, new ChartObservationId("current"))
            .BulletAxis(axis => { axis.ValueFormat(ChartValueFormat.Number("0%")); axis.Labels.Add(new ChartAxisLabel(0, "0%")); axis.Labels.Add(new ChartAxisLabel(.5, "50%")); axis.Labels.Add(new ChartAxisLabel(1, "100%")); });
        var queue = ChartSeries.CreateBullet(new ChartSeriesId("queue"), "Queue", new ChartBulletValue(1250, 900, 100, 1100, new[] { 500d, 900 }))
            .ObservationId(0, new ChartObservationId("current"))
            .BulletAxis(axis => { axis.Reversed = true; axis.TickCount = 3; axis.ValueFormat(ChartValueFormat.Number("0' jobs'")); });
        return Chart.Create().Size(compact ? 390 : 760, vertical ? 480 : 340).Title("Independent operating measurements")
            .Theme(VisualTheme.Graphite()).ThemeMode(mode).Legend(false).AddSeries(load).AddSeries(queue)
            .Bullet(options => { options.IndependentAxes = true; options.Orientation = vertical ? ChartOrientation.Vertical : ChartOrientation.Horizontal; });
    }
}
#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 = IndependentBulletRecipe.Create("compact", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(390, 218)), theme, mode,
    new VisualFrame("Independent operating measurements", "Separate domains and source units share horizontal or vertical tracks", 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>Different measurement units retain independent domains, captions and targets in horizontal or vertical bullet tracks.</summary>
public static class IndependentBulletRecipe {
    public static Chart Create(string variant = "wide", ThemeMode mode = ThemeMode.Light) {
        if (variant is not ("wide" or "compact" or "vertical" or "compact-vertical")) throw new ArgumentOutOfRangeException(nameof(variant));
        var compact = variant.StartsWith("compact", StringComparison.Ordinal); var vertical = variant.EndsWith("vertical", StringComparison.Ordinal);
        var load = ChartSeries.CreateBullet(new ChartSeriesId("load"), "Capacity", new ChartBulletValue(.72, .8, 0, 1, new[] { .5, .8 }))
            .ObservationId(0, new ChartObservationId("current"))
            .BulletAxis(axis => { axis.ValueFormat(ChartValueFormat.Number("0%")); axis.Labels.Add(new ChartAxisLabel(0, "0%")); axis.Labels.Add(new ChartAxisLabel(.5, "50%")); axis.Labels.Add(new ChartAxisLabel(1, "100%")); });
        var queue = ChartSeries.CreateBullet(new ChartSeriesId("queue"), "Queue", new ChartBulletValue(1250, 900, 100, 1100, new[] { 500d, 900 }))
            .ObservationId(0, new ChartObservationId("current"))
            .BulletAxis(axis => { axis.Reversed = true; axis.TickCount = 3; axis.ValueFormat(ChartValueFormat.Number("0' jobs'")); });
        return Chart.Create().Size(compact ? 390 : 760, vertical ? 480 : 340).Title("Independent operating measurements")
            .Theme(VisualTheme.Graphite()).ThemeMode(mode).Legend(false).AddSeries(load).AddSeries(queue)
            .Bullet(options => { options.IndependentAxes = true; options.Orientation = vertical ? ChartOrientation.Vertical : ChartOrientation.Horizontal; });
    }
}