Preview


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.
#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 = WordCloudRecipe.Create("compact", mode);
var context = new VisualRenderContext(
new VisualLayoutOptions(new VisualSize(360, 360)), theme, mode,
new VisualFrame("Topics in service observations", "", 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>Deterministic placement of weighted service-observation terms.</summary>
public static class WordCloudRecipe {
public static Chart Create(string variant = "wide", ThemeMode mode = ThemeMode.Light) {
// How often each topic appeared in a quarter of service review notes.
var terms = new (string Text, double Mentions)[] {
("Availability", 96), ("Identity", 81), ("Latency", 74), ("Network", 69), ("Storage", 61), ("Recovery", 57),
("Capacity", 52), ("Backups", 47), ("Certificates", 44), ("Patching", 41), ("Monitoring", 38), ("Access reviews", 35),
("DNS", 33), ("Licensing", 30), ("Firewall", 28), ("Replication", 26), ("Alerts", 24), ("Onboarding", 22),
("Encryption", 20), ("Audit", 19), ("Change control", 18), ("Escalation", 16), ("Runbooks", 15), ("MFA", 14),
("Retention", 13), ("Cost", 12), ("Vendors", 11), ("Training", 10), ("Load balancing", 9), ("Failover", 9),
("Inventory", 8), ("Tickets", 8), ("Compliance", 7), ("Endpoints", 7), ("Mail flow", 6), ("Quotas", 6)
};
var count = variant == "compact" ? 20 : terms.Length;
return Chart.Create().AddWordCloud("Mentions", terms.Take(count).Select(term => new ChartWordCloudItem(term.Text, term.Mentions)).ToArray());
}
}
#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 = WordCloudRecipe.Create("compact", mode);
var context = new VisualRenderContext(
new VisualLayoutOptions(new VisualSize(360, 360)), theme, mode,
new VisualFrame("Topics in service observations", "", 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>Deterministic placement of weighted service-observation terms.</summary>
public static class WordCloudRecipe {
public static Chart Create(string variant = "wide", ThemeMode mode = ThemeMode.Light) {
// How often each topic appeared in a quarter of service review notes.
var terms = new (string Text, double Mentions)[] {
("Availability", 96), ("Identity", 81), ("Latency", 74), ("Network", 69), ("Storage", 61), ("Recovery", 57),
("Capacity", 52), ("Backups", 47), ("Certificates", 44), ("Patching", 41), ("Monitoring", 38), ("Access reviews", 35),
("DNS", 33), ("Licensing", 30), ("Firewall", 28), ("Replication", 26), ("Alerts", 24), ("Onboarding", 22),
("Encryption", 20), ("Audit", 19), ("Change control", 18), ("Escalation", 16), ("Runbooks", 15), ("MFA", 14),
("Retention", 13), ("Cost", 12), ("Vendors", 11), ("Training", 10), ("Load balancing", 9), ("Failover", 9),
("Inventory", 8), ("Tickets", 8), ("Compliance", 7), ("Endpoints", 7), ("Mail flow", 6), ("Quotas", 6)
};
var count = variant == "compact" ? 20 : terms.Length;
return Chart.Create().AddWordCloud("Mentions", terms.Take(count).Select(term => new ChartWordCloudItem(term.Text, term.Mentions)).ToArray());
}
}