# Pressure against operating bands · Gauge

Preview

![Pressure against operating bands](combined-gauge-wide-light.png)

![Pressure against operating bands](combined-gauge-wide-dark.png)

760 × 440 pixels

## Create this example

Create a console project, add the ChartForgeX and ChartForgeX.Interactivity.Html packages, 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](combined-gauge-wide-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 = CombinedGaugeRecipe.Create("wide", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(760, 440)), theme, mode,
    new VisualFrame("Pressure against operating bands", "Arc, needle and independently painted semantic bands", 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>A single reading shown with an arc, needle, explicit references and independently painted semantic bands.</summary>
public static class CombinedGaugeRecipe {
    public static Chart Create(string variant = "wide", ThemeMode mode = ThemeMode.Light) {
        if (variant is not ("wide" or "compact")) throw new ArgumentOutOfRangeException(nameof(variant));
        var compact = variant == "compact";
        var series = ChartSeries.CreateGauge(new ChartSeriesId("pressure"), "Pressure",
            new ChartGaugeValue(3.25, 2, 3, new[] { new ChartGaugeTarget(2.4, "Minimum"), new ChartGaugeTarget(2.8, "Target") }), ChartColor.FromHex("#176B88"))
            .ObservationId(0, new ChartObservationId("current"));
        return Chart.Create().Size(compact ? 390 : 760, compact ? 360 : 440).Title("Pressure against operating bands")
            .Theme(VisualTheme.Graphite()).ThemeMode(mode).Legend(false).AddSeries(series)
            .ValueFormat(ChartValueFormat.Number("0.00' MPa'"))
            .Gauge(options => {
                options.Form = ChartGaugeForm.ArcWithNeedle; options.StartAngleDegrees = 180; options.SweepAngleDegrees = 180;
                options.TickCount = 5; options.BandGap = 4; options.NeedleColor = ChartColor.FromHex("#9D3C20"); options.Caption = "Raw reading above the operating range";
                options.Bands.Add(new ChartGaugeBand(2, 2.4, ChartSeriesState.Warning, ChartColor.FromHex("#D4A72C"), .8));
                options.Bands.Add(new ChartGaugeBand(2.4, 2.8, ChartSeriesState.Success, ChartColor.FromHex("#178266")));
                options.Bands.Add(new ChartGaugeBand(2.8, 3, ChartSeriesState.Danger, ChartColor.FromHex("#C34D43"), .85));
            });
    }
}
```

```
#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 = CombinedGaugeRecipe.Create("wide", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(760, 440)), theme, mode,
    new VisualFrame("Pressure against operating bands", "Arc, needle and independently painted semantic bands", 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>A single reading shown with an arc, needle, explicit references and independently painted semantic bands.</summary>
public static class CombinedGaugeRecipe {
    public static Chart Create(string variant = "wide", ThemeMode mode = ThemeMode.Light) {
        if (variant is not ("wide" or "compact")) throw new ArgumentOutOfRangeException(nameof(variant));
        var compact = variant == "compact";
        var series = ChartSeries.CreateGauge(new ChartSeriesId("pressure"), "Pressure",
            new ChartGaugeValue(3.25, 2, 3, new[] { new ChartGaugeTarget(2.4, "Minimum"), new ChartGaugeTarget(2.8, "Target") }), ChartColor.FromHex("#176B88"))
            .ObservationId(0, new ChartObservationId("current"));
        return Chart.Create().Size(compact ? 390 : 760, compact ? 360 : 440).Title("Pressure against operating bands")
            .Theme(VisualTheme.Graphite()).ThemeMode(mode).Legend(false).AddSeries(series)
            .ValueFormat(ChartValueFormat.Number("0.00' MPa'"))
            .Gauge(options => {
                options.Form = ChartGaugeForm.ArcWithNeedle; options.StartAngleDegrees = 180; options.SweepAngleDegrees = 180;
                options.TickCount = 5; options.BandGap = 4; options.NeedleColor = ChartColor.FromHex("#9D3C20"); options.Caption = "Raw reading above the operating range";
                options.Bands.Add(new ChartGaugeBand(2, 2.4, ChartSeriesState.Warning, ChartColor.FromHex("#D4A72C"), .8));
                options.Bands.Add(new ChartGaugeBand(2.4, 2.8, ChartSeriesState.Success, ChartColor.FromHex("#178266")));
                options.Bands.Add(new ChartGaugeBand(2.8, 3, ChartSeriesState.Danger, ChartColor.FromHex("#C34D43"), .85));
            });
    }
}
```

<!-- PowerForge markdown artifact sha256:0F94C700DCA4266B8724292078344EBC1E4C686F924CD426A9FDBDF3176C31B6 -->
