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.
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
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 = VisualThemeMode.Light;
var theme = VisualTheme.Graphite();
var model = CalendarHeatmapColorDimensionRecipe.Create("compact-color-dimension", mode);
var context = new VisualRenderContext(
new VisualLayoutOptions(new VisualSize(360, 360)), theme, mode,
new VisualFrame("Daily average temperature", "Temperature captions use their own format and culture", 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());
/// <summary>Formats daily temperature independently from the calendar's numeric observations.</summary>
public static class CalendarHeatmapColorDimensionRecipe {
/// <summary>Creates a temperature calendar with Polish number formatting and a named color dimension.</summary>
public static Chart Create(string variant = "color-dimension", VisualThemeMode mode = VisualThemeMode.Light) {
if (variant is not ("color-dimension" or "compact-color-dimension")) throw new ArgumentOutOfRangeException(nameof(variant));
var colors = VisualTheme.Graphite().Resolve(mode);
return Chart.Create().ConfigureLabels(labels => labels.NoData = "Not sampled")
.ConfigureCalendar(options => options.FirstDayOfWeek = DayOfWeek.Monday)
.AddCalendarHeatmap("Daily mean", Enumerable.Range(0, 120)
.Where(index => index % 7 != 0 && index % 9 != 0)
.Select(index => new ChartCalendarHeatmapItem(new DateTime(2026, 1, 1).AddDays(index), index * 2.5 % 13)),
id: new ChartSeriesId("daily-mean"))
.WithHeatmapColorScale(ChartColorScale.Sequential(colors.SequentialRamp).WithValueRange(0, 12)
.WithLabels("Cool", null, "Warm").WithNoDataColor(colors.Border))
.ConfigureHeatmapColorDimension(options => {
options.Name = "Temperature"; options.ValueFormat = ChartValueFormat.Number("0.0 '°C'", CultureInfo.GetCultureInfo("pl-PL"));
options.LegendStyle = ChartColorLegendStyle.Auto;
});
}
}
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
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 = VisualThemeMode.Dark;
var theme = VisualTheme.Graphite();
var model = CalendarHeatmapColorDimensionRecipe.Create("compact-color-dimension", mode);
var context = new VisualRenderContext(
new VisualLayoutOptions(new VisualSize(360, 360)), theme, mode,
new VisualFrame("Daily average temperature", "Temperature captions use their own format and culture", 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());
/// <summary>Formats daily temperature independently from the calendar's numeric observations.</summary>
public static class CalendarHeatmapColorDimensionRecipe {
/// <summary>Creates a temperature calendar with Polish number formatting and a named color dimension.</summary>
public static Chart Create(string variant = "color-dimension", VisualThemeMode mode = VisualThemeMode.Light) {
if (variant is not ("color-dimension" or "compact-color-dimension")) throw new ArgumentOutOfRangeException(nameof(variant));
var colors = VisualTheme.Graphite().Resolve(mode);
return Chart.Create().ConfigureLabels(labels => labels.NoData = "Not sampled")
.ConfigureCalendar(options => options.FirstDayOfWeek = DayOfWeek.Monday)
.AddCalendarHeatmap("Daily mean", Enumerable.Range(0, 120)
.Where(index => index % 7 != 0 && index % 9 != 0)
.Select(index => new ChartCalendarHeatmapItem(new DateTime(2026, 1, 1).AddDays(index), index * 2.5 % 13)),
id: new ChartSeriesId("daily-mean"))
.WithHeatmapColorScale(ChartColorScale.Sequential(colors.SequentialRamp).WithValueRange(0, 12)
.WithLabels("Cool", null, "Warm").WithNoDataColor(colors.Border))
.ConfigureHeatmapColorDimension(options => {
options.Name = "Temperature"; options.ValueFormat = ChartValueFormat.Number("0.0 '°C'", CultureInfo.GetCultureInfo("pl-PL"));
options.LegendStyle = ChartColorLegendStyle.Auto;
});
}
}