← Gallery

Bubble

Workload, requests and temperature

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

Preview
Workload, requests and temperatureChart with 1 data series: Recorded batches.Workload, requests and temperatureTemperature captions use their own format and cultureRecorded batchesRecorded batches · TemperatureNot sampledNot sampledCold · < 0,0 °CCold · < 0,0 °CMild · 0,0 °C ≤ value < 15,0 °CMild · 0,0 °C ≤ value < 15,0 °CWarm · ≥ 15,0 °CWarm · ≥ 15,0 °C020406080100Batch size (items)0.0 min50.0 minProcessing time (minutes)
Workload, requests and temperature
Workload, requests and temperatureChart with 1 data series: Recorded batches.Workload, requests and temperatureTemperature captions use their own format and cultureRecorded batchesRecorded batches · TemperatureNot sampledNot sampledCold · < 0,0 °CCold · < 0,0 °CMild · 0,0 °C ≤ value < 15,0 °CMild · 0,0 °C ≤ value < 15,0 °CWarm · ≥ 15,0 °CWarm · ≥ 15,0 °C020406080100Batch size (items)0.0 min50.0 minProcessing time (minutes)
Workload, requests and temperature
360 × 360 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.

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
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 = VisualThemeMode.Light;
var theme = VisualTheme.Graphite();
var model = BubbleColorDimensionRecipe.Create("compact-color-dimension", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(360, 360)), theme, mode,
    new VisualFrame("Workload, requests and temperature", "Temperature captions use their own format and culture", 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());

/// <summary>Formats bubble temperature separately from processing time and request volume.</summary>
public static class BubbleColorDimensionRecipe {
    /// <summary>Creates the selected example without choosing a renderer or export backend.</summary>
    public static Chart Create(string variant = "color-dimension", VisualThemeMode mode = VisualThemeMode.Light) {
        if (variant is not ("color-dimension" or "compact-color-dimension")) throw new ArgumentOutOfRangeException(nameof(variant));
        return ColorDimension(mode);
    }

    private static Chart ColorDimension(VisualThemeMode mode) {
        var colors = VisualTheme.Graphite().Resolve(mode);
        var minutes = new[] { 18d, 30, 24, 44, 32 };
        var temperatures = new double?[] { -12, 0, null, 2.5, 22.5 };
        var sizes = new[] { 9d, 36, 81, 49, 25 };
        var recorded = ChartSeries.CreateBubble(new ChartSeriesId("recorded-batches"), "Recorded batches", temperatures.Select((value, index) =>
            new ChartBubble((index + 1) * 16, minutes[index], sizes[index]).WithColorValue(value)));
        recorded.WithColorScale(ChartColorScale.Discrete(new[] {
                new ChartColorBand(0, colors.Palette[0], "Cold"),
                new ChartColorBand(15, colors.Status.Medium.Fill, "Mild"),
                new ChartColorBand(null, colors.Status.Critical.Fill, "Warm")
            }).WithNoDataColor(colors.Border)).ConfigureColorDimension(options => {
                options.Name = "Temperature";
                options.ValueFormat = ChartValueFormat.Number("0.0 '°C'", CultureInfo.GetCultureInfo("pl-PL"));
                options.LegendStyle = ChartColorLegendStyle.Auto;
            });
        return NumericAxes().ConfigureLabels(labels => labels.NoData = "Not sampled")
            .WithValueFormat(ChartValueFormat.Number("0.0 'min'", CultureInfo.InvariantCulture)).AddSeries(recorded);
    }

    private static Chart NumericAxes() => Chart.Create().WithXAxis("Batch size (items)").WithYAxis("Processing time (minutes)")
        .WithXAxisBounds(0, 100).WithYAxisBounds(0, 60).WithDataLabels(false);
}
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
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 = VisualThemeMode.Dark;
var theme = VisualTheme.Graphite();
var model = BubbleColorDimensionRecipe.Create("compact-color-dimension", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(360, 360)), theme, mode,
    new VisualFrame("Workload, requests and temperature", "Temperature captions use their own format and culture", 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());

/// <summary>Formats bubble temperature separately from processing time and request volume.</summary>
public static class BubbleColorDimensionRecipe {
    /// <summary>Creates the selected example without choosing a renderer or export backend.</summary>
    public static Chart Create(string variant = "color-dimension", VisualThemeMode mode = VisualThemeMode.Light) {
        if (variant is not ("color-dimension" or "compact-color-dimension")) throw new ArgumentOutOfRangeException(nameof(variant));
        return ColorDimension(mode);
    }

    private static Chart ColorDimension(VisualThemeMode mode) {
        var colors = VisualTheme.Graphite().Resolve(mode);
        var minutes = new[] { 18d, 30, 24, 44, 32 };
        var temperatures = new double?[] { -12, 0, null, 2.5, 22.5 };
        var sizes = new[] { 9d, 36, 81, 49, 25 };
        var recorded = ChartSeries.CreateBubble(new ChartSeriesId("recorded-batches"), "Recorded batches", temperatures.Select((value, index) =>
            new ChartBubble((index + 1) * 16, minutes[index], sizes[index]).WithColorValue(value)));
        recorded.WithColorScale(ChartColorScale.Discrete(new[] {
                new ChartColorBand(0, colors.Palette[0], "Cold"),
                new ChartColorBand(15, colors.Status.Medium.Fill, "Mild"),
                new ChartColorBand(null, colors.Status.Critical.Fill, "Warm")
            }).WithNoDataColor(colors.Border)).ConfigureColorDimension(options => {
                options.Name = "Temperature";
                options.ValueFormat = ChartValueFormat.Number("0.0 '°C'", CultureInfo.GetCultureInfo("pl-PL"));
                options.LegendStyle = ChartColorLegendStyle.Auto;
            });
        return NumericAxes().ConfigureLabels(labels => labels.NoData = "Not sampled")
            .WithValueFormat(ChartValueFormat.Number("0.0 'min'", CultureInfo.InvariantCulture)).AddSeries(recorded);
    }

    private static Chart NumericAxes() => Chart.Create().WithXAxis("Batch size (items)").WithYAxis("Processing time (minutes)")
        .WithXAxisBounds(0, 100).WithYAxisBounds(0, 60).WithDataLabels(false);
}