# Small-multiple report grid

Facet typed records into a deterministic multi-panel chart report with shared axes and pages.

 [All examples](/examples/) Static Grid 

 report-grid.svg  [SVG 165.2 KB](/site/examples/report-grid-light.svg) [SVG 165.2 KB](/site/examples/report-grid-dark.svg) [PNG 70 KB](/site/examples/report-grid-light.png) [PNG 70 KB](/site/examples/report-grid-dark.png) [HTML](/site/examples/report-grid-light.html) [HTML](/site/examples/report-grid-dark.html) [C# program](/site/examples/report-grid.csharp.txt)  

 ![Small-multiple report grid: the SVG this program renders.](/site/examples/report-grid-light.svg) ![Small-multiple report grid: the SVG this program renders, dark theme.](/site/examples/report-grid-dark.svg) 

Rendered by ChartForgeX from the program below. The files follow the page theme.

Typed records become one chart per site, laid out as a grid. The output above is this program's SVG; the selected grid theme applies to every panel. Run the complete program with `--dark` for the dark theme.

## Load typed records

`ChartDataset<T>` keeps your own record type, so the chart reads properties instead of parallel arrays.

```csharp
using System;
using System.Linq;
using ChartForgeX;
using ChartForgeX.Core;
using ChartForgeX.Data;
using ChartForgeX.Themes;

var mode = args.Contains("--dark")
    ? ThemeMode.Dark : ThemeMode.Light;

var samples = ChartDataset<CpuSample>.From(new CpuSample[] {
    new("Warsaw", 1, 35), new("Warsaw", 2, 42),
    new("Warsaw", 3, 39), new("Warsaw", 4, 51),
    new("London", 1, 48), new("London", 2, 61),
    new("London", 3, 57), new("London", 4, 66),
    new("Berlin", 1, 22), new("Berlin", 2, 28),
    new("Berlin", 3, 31), new("Berlin", 4, 36),
    new("Madrid", 1, 51), new("Madrid", 2, 47),
    new("Madrid", 3, 44), new("Madrid", 4, 39)
});
```

## Facet into a grid

`ChartGrid.FromFacets` groups the records by a key and builds one chart per group with the factory you pass. Groups keep their input order.

```csharp
var report = ChartGrid.FromFacets(
    samples,
    sample => sample.Site,
    (site, rows) => Chart.Create()
        .Title(site)
        .YAxis(y => y.Title("CPU (%)"))
        .AddLine("CPU", rows,
            sample => sample.Minute, sample => sample.Cpu),
    columns: 2).ThemeMode(mode);
```

## Save the report

The grid renders as one image, so a report, an email or a wiki page gets every panel in a single file.

```csharp
report.SavePng("cpu-by-site.png");
report.SaveSvg("cpu-by-site.svg");
```

## Declare the record

Any record or class works; the selectors above read its properties.

```csharp
/// <summary>One CPU observation from a named site.</summary>
public sealed record CpuSample(string Site, double Minute, double Cpu);
```

Use `ChartGrid` for chart-only small multiples. Use visual blocks or a visual canvas when the report also needs exact facts, lists, or positioned artwork.

<!-- PowerForge markdown source sha256:EBDB711F86BF8B850A72282C7FEAF36A4A93ABEF3DFF6700C3E63EC82A3A23DD; title=True -->

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