#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 = HeatmapCategoryRecipe.Create("options", mode);
var context = new VisualRenderContext(
new VisualLayoutOptions(new VisualSize(800, 440)), theme, mode,
new VisualFrame("Coverage across service areas", "", 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
/// Shows assessment states as categorical heatmap cells.
public static class HeatmapCategoryRecipe {
/// Creates status rows with explicit category colors and a production group.
public static Chart Create(string variant = "options", ThemeMode mode = ThemeMode.Light) {
if (variant != "options") throw new ArgumentOutOfRangeException(nameof(variant));
var colors = VisualTheme.Graphite().Resolve(mode);
var primary = ChartSeries.CreateHeatmapCategoryRow(new ChartSeriesId("primary"), "Primary", new ChartHeatmapCell?[] {
new("pass", "Ready", "Assessment passed"), new("warning", "Review"), null, new("pass", "Ready")
}, "Production");
var secondary = ChartSeries.CreateHeatmapCategoryRow(new ChartSeriesId("secondary"), "Secondary", new ChartHeatmapCell?[] {
new("pass"), new("pass"), new("warning"), new("pass")
}, "Production");
return Chart.Create().StateCategories(new ChartStateCategory("pass", "Available", colors.Status.Pass.Fill),
new ChartStateCategory("warning", "Review", colors.Status.Medium.Fill, ChartStatePattern.Hatched),
new ChartStateCategory("critical", "Unavailable", colors.Status.Critical.Fill, ChartStatePattern.CrossHatched))
.XLabels("Identity", "Network", "Storage", "Backup")
.AddSeries(primary).AddSeries(secondary);
}
}