# Daily activity across four months · Calendar Heatmap

Preview

![Daily activity across four months](family-calendar-heatmap-color-scale-light.png)

![Daily activity across four months](family-calendar-heatmap-color-scale-dark.png)

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](family-calendar-heatmap-color-scale-light.gallery.csharp.txt) 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 = CalendarHeatmapColorScaleRecipe.Create("color-scale", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(800, 440)), theme, mode,
    new VisualFrame("Daily activity across four months", "Every observed value shares one scale; missing days stay distinct", 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>Colors dated activity from quiet to busy on a fixed numeric scale.</summary>
public static class CalendarHeatmapColorScaleRecipe {
    /// <summary>Creates a Monday-first calendar with an explicit activity range and missing-data color.</summary>
    public static Chart Create(string variant = "color-scale", ThemeMode mode = ThemeMode.Light) {
        if (variant is not ("color-scale" or "compact-color-scale")) throw new ArgumentOutOfRangeException(nameof(variant));
        var colors = VisualTheme.Graphite().Resolve(mode);
        return Chart.Create().Calendar(options => options.FirstDayOfWeek = DayOfWeek.Monday)
            .AddCalendarHeatmap("Daily observations", Enumerable.Range(0, 120)
                .Where(index => index % 7 != 0 && index % 9 != 0)
                .Select(index => new ChartCalendarHeatmapItem(new DateTime(2026, 1, 1).AddDays(index), index * 7 % 13)),
                id: new ChartSeriesId("daily-observations"))
            .Heatmap(h => h.ColorScale(ChartColorScale.Sequential(colors.SequentialRamp).WithValueRange(0, 12)
                .WithLabels("Quiet", null, "Busy").WithNoDataColor(colors.Border)));
    }
}
```

```
#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 = CalendarHeatmapColorScaleRecipe.Create("color-scale", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(800, 440)), theme, mode,
    new VisualFrame("Daily activity across four months", "Every observed value shares one scale; missing days stay distinct", 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>Colors dated activity from quiet to busy on a fixed numeric scale.</summary>
public static class CalendarHeatmapColorScaleRecipe {
    /// <summary>Creates a Monday-first calendar with an explicit activity range and missing-data color.</summary>
    public static Chart Create(string variant = "color-scale", ThemeMode mode = ThemeMode.Light) {
        if (variant is not ("color-scale" or "compact-color-scale")) throw new ArgumentOutOfRangeException(nameof(variant));
        var colors = VisualTheme.Graphite().Resolve(mode);
        return Chart.Create().Calendar(options => options.FirstDayOfWeek = DayOfWeek.Monday)
            .AddCalendarHeatmap("Daily observations", Enumerable.Range(0, 120)
                .Where(index => index % 7 != 0 && index % 9 != 0)
                .Select(index => new ChartCalendarHeatmapItem(new DateTime(2026, 1, 1).AddDays(index), index * 7 % 13)),
                id: new ChartSeriesId("daily-observations"))
            .Heatmap(h => h.ColorScale(ChartColorScale.Sequential(colors.SequentialRamp).WithValueRange(0, 12)
                .WithLabels("Quiet", null, "Busy").WithNoDataColor(colors.Border)));
    }
}
```

<!-- PowerForge markdown artifact sha256:D0F2174E9D55DECF24CAFBB5326A7CB707322F3BA0A322C73D461BA1F1AAAAA1 -->
