← Gallery

Heatmap

Coverage across service areas

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

Preview
Coverage across service areasChart with 6 data series: London, Frankfurt, Warsaw, New York, Singapore, Sydney.London, Identity: 97%London, Network: 96%London, Storage: 74%London, Backup: 66%London, Access: 99%London, Recovery: 61%Frankfurt, Identity: 99%Frankfurt, Network: 87%Frankfurt, Storage: 69%Frankfurt, Backup: 70%Frankfurt, Access: 94%Frankfurt, Recovery: 52%Warsaw, Identity: 92%Warsaw, Network: 76%Warsaw, Storage: 71%Warsaw, Backup: 66%Warsaw, Access: 82%Warsaw, Recovery: 50%New York, Identity: 91%New York, Network: 85%New York, Storage: 82%New York, Backup: 66%New York, Access: 87%New York, Recovery: 63%Singapore, Identity: 80%Singapore, Network: 82%Singapore, Storage: 68%Singapore, Backup: 51%Singapore, Access: 83%Singapore, Recovery: 54%Sydney, Identity: 83%Sydney, Network: 80%Sydney, Storage: 58%Sydney, Backup: 52%Sydney, Access: 85%Sydney, Recovery: 44%44%50%60%70%80%90%99%
Coverage across service areas
Coverage across service areasChart with 6 data series: London, Frankfurt, Warsaw, New York, Singapore, Sydney.London, Identity: 97%London, Network: 96%London, Storage: 74%London, Backup: 66%London, Access: 99%London, Recovery: 61%Frankfurt, Identity: 99%Frankfurt, Network: 87%Frankfurt, Storage: 69%Frankfurt, Backup: 70%Frankfurt, Access: 94%Frankfurt, Recovery: 52%Warsaw, Identity: 92%Warsaw, Network: 76%Warsaw, Storage: 71%Warsaw, Backup: 66%Warsaw, Access: 82%Warsaw, Recovery: 50%New York, Identity: 91%New York, Network: 85%New York, Storage: 82%New York, Backup: 66%New York, Access: 87%New York, Recovery: 63%Singapore, Identity: 80%Singapore, Network: 82%Singapore, Storage: 68%Singapore, Backup: 51%Singapore, Access: 83%Singapore, Recovery: 54%Sydney, Identity: 83%Sydney, Network: 80%Sydney, Storage: 58%Sydney, Backup: 52%Sydney, Access: 85%Sydney, Recovery: 44%44%50%60%70%80%90%99%
Coverage across service areas
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 = HeatmapRecipe.Create("wide", 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

/// <summary>Shows monthly coverage measurements across service areas.</summary>
public static class HeatmapRecipe {
    /// <summary>Creates numeric coverage rows; the sparse variant preserves empty cell positions.</summary>
    public static Chart Create(string variant = "wide", ThemeMode mode = ThemeMode.Light) {
        if (variant is not ("wide" or "compact" or "sparse" or "compact-options")) throw new ArgumentOutOfRangeException(nameof(variant));
        if (variant == "sparse") return Chart.Create().XLabels("Identity", "Network", "Storage", "Backup", "Access", "Recovery")
            .AddHeatmapRow("Primary", new double?[] { 92, null, null, 70, null, 41 }, id: new ChartSeriesId("primary-measurements"))
            .AddHeatmapRow("Secondary", new double?[] { null, 84, null, null, 90, null }, id: new ChartSeriesId("secondary-measurements"))
            .Heatmap(h => h.Scale(ChartHeatmapScale.Sequential).CellGap(3).CellRadius(3).ValueTextMode(ChartHeatmapValueTextMode.Auto));

        var areas = new[] { "Identity", "Network", "Storage", "Backup", "Access", "Recovery" };
        var sites = variant == "wide"
            ? new[] { "London", "Frankfurt", "Warsaw", "New York", "Singapore", "Sydney" }
            : new[] { "London", "Warsaw", "New York", "Sydney" };
        // Each service area has its own baseline; each site is a little ahead or behind, with uneven cells.
        var baselines = new[] { 91d, 84, 72, 63, 88, 55 };
        var siteOffsets = new[] { 6d, 3, -2, 4, -6, -9 };
        var chart = Chart.Create().XLabels(areas);
        for (var row = 0; row < sites.Length; row++) {
            var site = Array.IndexOf(new[] { "London", "Frankfurt", "Warsaw", "New York", "Singapore", "Sydney" }, sites[row]);
            var values = areas.Select((_, column) => (double?)Math.Min(99, Math.Round(
                baselines[column] + siteOffsets[site] + Math.Sin(column * 1.9 + site * 1.3) * 6))).ToArray();
            chart.AddHeatmapRow(sites[row], values, id: new ChartSeriesId(sites[row].Replace(" ", "-").ToLowerInvariant() + "-coverage"));
        }
        return chart.Heatmap(heatmap => heatmap.ColorDimension(dimension => dimension.Name = "Coverage")).Heatmap(h => h.Scale(ChartHeatmapScale.Sequential).CellGap(3).CellRadius(3).ValueTextMode(ChartHeatmapValueTextMode.Auto))
            .ValueFormat(ChartValueFormat.Number("0'%'", CultureInfo.InvariantCulture));
    }
}
#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 = HeatmapRecipe.Create("wide", 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

/// <summary>Shows monthly coverage measurements across service areas.</summary>
public static class HeatmapRecipe {
    /// <summary>Creates numeric coverage rows; the sparse variant preserves empty cell positions.</summary>
    public static Chart Create(string variant = "wide", ThemeMode mode = ThemeMode.Light) {
        if (variant is not ("wide" or "compact" or "sparse" or "compact-options")) throw new ArgumentOutOfRangeException(nameof(variant));
        if (variant == "sparse") return Chart.Create().XLabels("Identity", "Network", "Storage", "Backup", "Access", "Recovery")
            .AddHeatmapRow("Primary", new double?[] { 92, null, null, 70, null, 41 }, id: new ChartSeriesId("primary-measurements"))
            .AddHeatmapRow("Secondary", new double?[] { null, 84, null, null, 90, null }, id: new ChartSeriesId("secondary-measurements"))
            .Heatmap(h => h.Scale(ChartHeatmapScale.Sequential).CellGap(3).CellRadius(3).ValueTextMode(ChartHeatmapValueTextMode.Auto));

        var areas = new[] { "Identity", "Network", "Storage", "Backup", "Access", "Recovery" };
        var sites = variant == "wide"
            ? new[] { "London", "Frankfurt", "Warsaw", "New York", "Singapore", "Sydney" }
            : new[] { "London", "Warsaw", "New York", "Sydney" };
        // Each service area has its own baseline; each site is a little ahead or behind, with uneven cells.
        var baselines = new[] { 91d, 84, 72, 63, 88, 55 };
        var siteOffsets = new[] { 6d, 3, -2, 4, -6, -9 };
        var chart = Chart.Create().XLabels(areas);
        for (var row = 0; row < sites.Length; row++) {
            var site = Array.IndexOf(new[] { "London", "Frankfurt", "Warsaw", "New York", "Singapore", "Sydney" }, sites[row]);
            var values = areas.Select((_, column) => (double?)Math.Min(99, Math.Round(
                baselines[column] + siteOffsets[site] + Math.Sin(column * 1.9 + site * 1.3) * 6))).ToArray();
            chart.AddHeatmapRow(sites[row], values, id: new ChartSeriesId(sites[row].Replace(" ", "-").ToLowerInvariant() + "-coverage"));
        }
        return chart.Heatmap(heatmap => heatmap.ColorDimension(dimension => dimension.Name = "Coverage")).Heatmap(h => h.Scale(ChartHeatmapScale.Sequential).CellGap(3).CellRadius(3).ValueTextMode(ChartHeatmapValueTextMode.Auto))
            .ValueFormat(ChartValueFormat.Number("0'%'", CultureInfo.InvariantCulture));
    }
}