← Gallery

Progress Bar

Progress in each row's units

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

Preview
Progress in each row's unitsProgress in each row's units with 1 data series: Delivery.
Progress in each row's units
Progress in each row's unitsProgress in each row's units with 1 data series: Delivery.
Progress in each row's units
760 × 195 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 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 = IndependentProgressRecipe.Create("wide", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(760, 195)), theme, mode,
    new VisualFrame("Progress in each row\u0027s units", "Retained row domains preserve fraction, count and signed measurements", 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>Identified progress rows retain their own measurement domain and source units.</summary>
public static class IndependentProgressRecipe {
    public static Chart Create(string variant = "wide", ThemeMode mode = ThemeMode.Light) {
        if (variant is not ("wide" or "compact")) throw new ArgumentOutOfRangeException(nameof(variant));
        var rows = ChartSeries.CreateProgressBars(new ChartSeriesId("delivery"), "Delivery", new[] {
            new ChartProgressItem("Reviewed fraction", .72, 0, 1),
            new ChartProgressItem("Verified jobs", 1250, 0, 2000),
            new ChartProgressItem("Temperature change", -8, -20, 20)
        }).ObservationId(0, new ChartObservationId("reviewed"))
            .ObservationId(1, new ChartObservationId("verified"))
            .ObservationId(2, new ChartObservationId("temperature"));
        return Chart.Create().Size(variant == "compact" ? 390 : 760, 340).Title("Progress in each row's units")
            .Theme(VisualTheme.Graphite()).ThemeMode(mode).Legend(false).AddSeries(rows);
    }
}
#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 = IndependentProgressRecipe.Create("wide", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(760, 195)), theme, mode,
    new VisualFrame("Progress in each row\u0027s units", "Retained row domains preserve fraction, count and signed measurements", 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>Identified progress rows retain their own measurement domain and source units.</summary>
public static class IndependentProgressRecipe {
    public static Chart Create(string variant = "wide", ThemeMode mode = ThemeMode.Light) {
        if (variant is not ("wide" or "compact")) throw new ArgumentOutOfRangeException(nameof(variant));
        var rows = ChartSeries.CreateProgressBars(new ChartSeriesId("delivery"), "Delivery", new[] {
            new ChartProgressItem("Reviewed fraction", .72, 0, 1),
            new ChartProgressItem("Verified jobs", 1250, 0, 2000),
            new ChartProgressItem("Temperature change", -8, -20, 20)
        }).ObservationId(0, new ChartObservationId("reviewed"))
            .ObservationId(1, new ChartObservationId("verified"))
            .ObservationId(2, new ChartObservationId("temperature"));
        return Chart.Create().Size(variant == "compact" ? 390 : 760, 340).Title("Progress in each row's units")
            .Theme(VisualTheme.Graphite()).ThemeMode(mode).Legend(false).AddSeries(rows);
    }
}