← 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 1 data series: Requests.Workload, time and request volumeExplore the data, then download the chart12345Workload batches010203040Time (minutes)
Workload, time and request volume
Workload, time and request volumeChart with 1 data series: Requests.Workload, time and request volumeExplore the data, then download the chart12345Workload batches010203040Time (minutes)
Workload, time and request volume
800 × 440 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 = BubbleRecipe.Create("wide", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(800, 440)), theme, mode,
    new VisualFrame("Workload, time and request volume", "Explore the data, then download the chart", 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>Plots request volume as bubble size against workload and processing time.</summary>
public static class BubbleRecipe {
    /// <summary>Creates the selected example without choosing a renderer or export backend.</summary>
    public static Chart Create(string variant = "wide", VisualThemeMode mode = VisualThemeMode.Light) {
        if (variant is not ("wide" or "compact" or "sparse")) throw new ArgumentOutOfRangeException(nameof(variant));
        return RequestVolume(variant).WithValueFormat(ChartValueFormat.Number("0.##", CultureInfo.InvariantCulture));
    }

    private static Chart RequestVolume(string variant) {
        var count = variant == "sparse" ? 2 : 5;
        var requests = ChartSeries.CreateBubble(new ChartSeriesId("requests"), "Requests",
            Enumerable.Range(1, count).Select(index => new ChartBubble(index, 20 + index * 5, index * index + 1)));
        return Chart.Create().WithXLabels("1", "2", "3", "4", "5", "6")
            .WithXAxis("Workload batches").WithYAxis("Time (minutes)").AddSeries(requests);
    }
}
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 = BubbleRecipe.Create("wide", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(800, 440)), theme, mode,
    new VisualFrame("Workload, time and request volume", "Explore the data, then download the chart", 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>Plots request volume as bubble size against workload and processing time.</summary>
public static class BubbleRecipe {
    /// <summary>Creates the selected example without choosing a renderer or export backend.</summary>
    public static Chart Create(string variant = "wide", VisualThemeMode mode = VisualThemeMode.Light) {
        if (variant is not ("wide" or "compact" or "sparse")) throw new ArgumentOutOfRangeException(nameof(variant));
        return RequestVolume(variant).WithValueFormat(ChartValueFormat.Number("0.##", CultureInfo.InvariantCulture));
    }

    private static Chart RequestVolume(string variant) {
        var count = variant == "sparse" ? 2 : 5;
        var requests = ChartSeries.CreateBubble(new ChartSeriesId("requests"), "Requests",
            Enumerable.Range(1, count).Select(index => new ChartBubble(index, 20 + index * 5, index * index + 1)));
        return Chart.Create().WithXLabels("1", "2", "3", "4", "5", "6")
            .WithXAxis("Workload batches").WithYAxis("Time (minutes)").AddSeries(requests);
    }
}