Preview


800 × 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 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 = CertificatesByIssuerRecipe.Create("issuers", mode);
var context = new VisualRenderContext(
new VisualLayoutOptions(new VisualSize(800, 440)), theme, mode,
new VisualFrame("Certificates issued per month", "Stacked by issuing authority, November 2025 to October 2026", 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>Builds certificates issued per month by issuer over the last year, as a certificate report shows it.</summary>
public static class CertificatesByIssuerRecipe {
/// <summary>Creates stacked monthly issuance; the compact variant keeps the same data.</summary>
public static Chart Create(string variant = "issuers", ThemeMode mode = ThemeMode.Light) {
if (variant is not ("issuers" or "compact-issuers")) throw new ArgumentOutOfRangeException(nameof(variant));
var months = Enumerable.Range(0, 12).Select(month => new DateTime(2025, 11, 1).AddMonths(month).ToString("MMM", CultureInfo.InvariantCulture)).ToArray();
var chart = Chart.Create().XLabels(months).Bars(b => b.Stacked()).YAxis(y => y.Title("Certificates"))
.ValueFormat(ChartValueFormat.Number("0", CultureInfo.InvariantCulture));
var issuers = new[] { ("lets-encrypt", "Let's Encrypt", 64), ("digicert", "DigiCert", 18), ("sectigo", "Sectigo", 11), ("internal-ca", "Internal CA", 7) };
foreach (var (id, name, typical) in issuers) {
// Renewals cluster every third month; the values are deterministic so the gallery stays reproducible.
var values = Enumerable.Range(0, 12).Select(month => new ChartPoint(month + 1, typical + (month % 3 == 0 ? typical / 3 : 0) - month % 4));
chart.AddSeries(ChartSeries.CreateBar(new ChartSeriesId(id), name, values));
}
return chart;
}
}
#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 = CertificatesByIssuerRecipe.Create("issuers", mode);
var context = new VisualRenderContext(
new VisualLayoutOptions(new VisualSize(800, 440)), theme, mode,
new VisualFrame("Certificates issued per month", "Stacked by issuing authority, November 2025 to October 2026", 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>Builds certificates issued per month by issuer over the last year, as a certificate report shows it.</summary>
public static class CertificatesByIssuerRecipe {
/// <summary>Creates stacked monthly issuance; the compact variant keeps the same data.</summary>
public static Chart Create(string variant = "issuers", ThemeMode mode = ThemeMode.Light) {
if (variant is not ("issuers" or "compact-issuers")) throw new ArgumentOutOfRangeException(nameof(variant));
var months = Enumerable.Range(0, 12).Select(month => new DateTime(2025, 11, 1).AddMonths(month).ToString("MMM", CultureInfo.InvariantCulture)).ToArray();
var chart = Chart.Create().XLabels(months).Bars(b => b.Stacked()).YAxis(y => y.Title("Certificates"))
.ValueFormat(ChartValueFormat.Number("0", CultureInfo.InvariantCulture));
var issuers = new[] { ("lets-encrypt", "Let's Encrypt", 64), ("digicert", "DigiCert", 18), ("sectigo", "Sectigo", 11), ("internal-ca", "Internal CA", 7) };
foreach (var (id, name, typical) in issuers) {
// Renewals cluster every third month; the values are deterministic so the gallery stays reproducible.
var values = Enumerable.Range(0, 12).Select(month => new ChartPoint(month + 1, typical + (month % 3 == 0 ? typical / 3 : 0) - month % 4));
chart.AddSeries(ChartSeries.CreateBar(new ChartSeriesId(id), name, values));
}
return chart;
}
}