← Gallery

Bubble

Workload, time and request volume

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

Preview
Workload, time and request volumeChart with 2 data series: Standard, Priority.Workload, time and request volumeEqual request volumes share a radius; values above 100retain their factsStandardPriority123Workload batches010203040Time (minutes)
Workload, time and request volume
Workload, time and request volumeChart with 2 data series: Standard, Priority.Workload, time and request volumeEqual request volumes share a radius; values above 100retain their factsStandardPriority123Workload batches010203040Time (minutes)
Workload, time and request volume
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 = BubbleMarkerOptionsRecipe.Create("compact-options", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(360, 360)), theme, mode,
    new VisualFrame("Workload, time and request volume", "Equal request volumes share a radius; values above 100 retain their facts", 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>Compares standard and priority observations with independent bubble markers.</summary>
public static class BubbleMarkerOptionsRecipe {
    /// <summary>Creates the selected example without choosing a renderer or export backend.</summary>
    public static Chart Create(string variant = "options", VisualThemeMode mode = VisualThemeMode.Light) {
        if (variant is not ("options" or "compact-options")) throw new ArgumentOutOfRangeException(nameof(variant));
        return MarkerOptions().WithValueFormat(ChartValueFormat.Number("0.##", CultureInfo.InvariantCulture));
    }

    private static Chart MarkerOptions() {
        var standard = ChartSeries.CreateBubble(new ChartSeriesId("standard"), "Standard", new[] {
            new ChartBubble(1, 18, 9), new ChartBubble(2, 30, 36), new ChartBubble(3, 24, 81)
        }).ConfigureMarkers(markers => markers.Shape = ChartMarkerShape.Circle);
        var priority = ChartSeries.CreateBubble(new ChartSeriesId("priority"), "Priority", new[] {
            new ChartBubble(1.5, 32, 16), new ChartBubble(2.5, 20, 36), new ChartBubble(3.5, 36, 200)
        }).ConfigureMarkers(markers => markers.Shape = ChartMarkerShape.Diamond);
        return Chart.Create().WithXAxis("Workload batches").WithYAxis("Time (minutes)")
            .AddSeries(standard).AddSeries(priority)
            .ConfigureBubble(bubble => { bubble.WithSizeDomain(0, 100); bubble.MinimumRadius = 3; bubble.MaximumRadius = 24; });
    }
}
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 = BubbleMarkerOptionsRecipe.Create("compact-options", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(360, 360)), theme, mode,
    new VisualFrame("Workload, time and request volume", "Equal request volumes share a radius; values above 100 retain their facts", 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>Compares standard and priority observations with independent bubble markers.</summary>
public static class BubbleMarkerOptionsRecipe {
    /// <summary>Creates the selected example without choosing a renderer or export backend.</summary>
    public static Chart Create(string variant = "options", VisualThemeMode mode = VisualThemeMode.Light) {
        if (variant is not ("options" or "compact-options")) throw new ArgumentOutOfRangeException(nameof(variant));
        return MarkerOptions().WithValueFormat(ChartValueFormat.Number("0.##", CultureInfo.InvariantCulture));
    }

    private static Chart MarkerOptions() {
        var standard = ChartSeries.CreateBubble(new ChartSeriesId("standard"), "Standard", new[] {
            new ChartBubble(1, 18, 9), new ChartBubble(2, 30, 36), new ChartBubble(3, 24, 81)
        }).ConfigureMarkers(markers => markers.Shape = ChartMarkerShape.Circle);
        var priority = ChartSeries.CreateBubble(new ChartSeriesId("priority"), "Priority", new[] {
            new ChartBubble(1.5, 32, 16), new ChartBubble(2.5, 20, 36), new ChartBubble(3.5, 36, 200)
        }).ConfigureMarkers(markers => markers.Shape = ChartMarkerShape.Diamond);
        return Chart.Create().WithXAxis("Workload batches").WithYAxis("Time (minutes)")
            .AddSeries(standard).AddSeries(priority)
            .ConfigureBubble(bubble => { bubble.WithSizeDomain(0, 100); bubble.MinimumRadius = 3; bubble.MaximumRadius = 24; });
    }
}