# belt-charts

> A CLI tool for generating charts from verbose data from belt

Latest version **1.25.0** (published 2026-11-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install belt-charts
pnpm add belt-charts
yarn add belt-charts
bun add belt-charts
```

Provides the command `belt-charts`.

## Health

**Score 60/100 (C)** — status: active.

Positive: no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 1.25.0 |
| Published | 2026-11-02 |
| First published | 2026-06-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=14.0.0 |
| Dependencies | 9 |
| Unpacked size | 1.4 MB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 4 |
| Author | abucnasty |
| Maintainers | abucnasty |
| Keywords | cli, charts, belt, benchmark, visualization, metrics |

## Links

- npm: https://www.npmjs.com/package/belt-charts
- Repository: https://github.com/abucnasty/belt-charts
- Homepage: https://github.com/abucnasty/belt-charts#readme
- Issues: https://github.com/abucnasty/belt-charts/issues
- npm.io page: https://npm.io/package/belt-charts

## Dependencies (9)

- [glob](https://npm.io/package/glob.md) ^11.0.3
- [chart.js](https://npm.io/package/chart.js.md) ^4.5.0
- [commander](https://npm.io/package/commander.md) ^14.0.0
- [minimatch](https://npm.io/package/minimatch.md) ^10.2.6
- [csv-writer](https://npm.io/package/csv-writer.md) ^1.6.0
- [skia-canvas](https://npm.io/package/skia-canvas.md) ^3.0.6
- [ffmpeg-static](https://npm.io/package/ffmpeg-static.md) ^5.3.0
- [chartjs-plugin-annotation](https://npm.io/package/chartjs-plugin-annotation.md) ^3.1.0
- [@sgratzl/chartjs-chart-boxplot](https://npm.io/package/@sgratzl/chartjs-chart-boxplot.md) ^4.4.4

## Alternatives

- [d3-force-3d](https://npm.io/package/d3-force-3d.md) — 1.0M weekly downloads
- [ng2-charts](https://npm.io/package/ng2-charts.md) — 486.8K weekly downloads
- [@arcgis/core](https://npm.io/package/@arcgis/core.md) — 257.8K weekly downloads
- [react-sparklines](https://npm.io/package/react-sparklines.md) — 249.3K weekly downloads
- [react-native-gifted-charts](https://npm.io/package/react-native-gifted-charts.md) — 182.3K weekly downloads

## Recent versions

- 1.25.0 (latest) — 2026-11-02
- 1.24.1 — 2026-10-30
- 1.24.0 — 2026-10-01
- 1.23.0 — 2026-10-01
- 1.22.0 — 2026-09-30
- 1.21.0 — 2026-09-30
- 1.20.1 — 2026-09-29
- 1.20.0 — 2026-09-29
- 1.19.1 — 2026-09-27
- 1.19.0 — 2026-09-25
- 1.18.1 — 2026-09-24
- 1.18.0 — 2026-09-23
- 1.17.0 — 2026-09-23
- 1.16.0 — 2026-09-23
- 1.15.0 — 2026-09-23
- … 22 more at https://npm.io/package/belt-charts/versions

## README

# belt-charts

[![npm version](https://img.shields.io/npm/v/belt-charts)](https://www.npmjs.com/package/belt-charts)

A CLI tool for generating charts and visualizations from Belt benchmark verbose metrics data.

## Installation

### From npm
```bash
npm install -g belt-charts
```

### For Development
```bash
npm install
npm run build
npm link
```

## Usage

After installation, the `belt-charts` command will be globally available:

```bash
belt-charts --help
```


## Command Reference

All commands share a common set of **base options**, plus command-specific options listed below.

### Base Options (all commands)

| Option | Default | Description |
|---|---|---|
| `[glob-pattern]` | *(see `--input`)* | Glob pattern for input CSV files, e.g. `"results/*.csv"`. Optional when `--input` is given |
| `--input <glob>[:<suffix>]` | *(none)* | Results files to chart. Repeatable, and combined with the positional pattern. An optional `:suffix` is appended to the label of every file of that input as `<label> (suffix)` (after `--name` / `--names-file` and the other label transforms), so two folders with the same file names chart together in one command — see “Several inputs” below |
| `--include <pattern>` | *(none)* | Only chart inputs whose base name or label matches this glob pattern. Repeatable (OR-matched) |
| `--exclude <pattern>` | *(none)* | Skip inputs whose base name or label matches this glob pattern. Repeatable; applied after `--include` |
| `-o, --output <file>` | `verbose_metrics.png` | Output file path. Use `.svg` for vector output |
| `-w, --width <px>` | `1400` | Chart width in pixels. Treated as a **minimum** by charts that auto-grow to fit their content — see “Auto-sizing” below |
| `-h, --height <px>` | `800` | Chart height in pixels. Treated as a **minimum** by charts that auto-grow to fit their content — see “Auto-sizing” below |
| `--scale <factor>` | `1` | Integer output pixel multiplier for higher-resolution PNG/MP4 output — see “High-resolution output” below. Ignored for `.svg` |
| `--font-scale <factor>` | `1` | Multiplies the size of all text — titles, legends, axis labels, value labels and the in-chart table — together with the layout measures that fit it (table row height, minimum bar row height), independent of `-w`, `-h` and `--scale`. Charts that auto-grow (see “Auto-sizing”) grow to fit the larger text; `-w` / `-h` stay the floor. e.g. `--font-scale 1.5` for slides |
| `--remove-first-ticks <n>` | `1` | Skip the first N ticks (removes benchmark warm-up spikes) |
| `--max-ticks <n>` | `0` | Only include ticks up to N. `0` = no limit |
| `--trim-prefix <string>` | `""` | Strip a common prefix from all file names in chart labels |
| `--name <baseName>=<label>` | *(none)* | Override the chart label for one input file. Repeatable — use once per file. The key is the pre-trim base name (filename minus `.csv` / `_verbose_metrics`). Takes precedence over `--trim-prefix`. In per-run charts the custom label becomes the base: `<label> (run N)`. |
| `--names-file <path>` | `""` | Path to a names-mapping file. Each non-blank, non-comment line: `baseName=label`. Lines starting with `#` are comments. `--name` flags override entries in this file on duplicate keys. |
| `--metrics <list>` | *default set* | Comma-separated list of metric names to include, e.g. `"wholeUpdate,entityUpdate"`. Use `*` for all defaults |
| `--min-percent <number>` | `0` | Hide any metric/entity whose max value never exceeds this % of the reference total across all files. `0` = no filter |
| `--trim-substring <string>` | *(none)* | Remove all occurrences of an exact substring from chart labels. Repeatable — use once per substring. Applied after `--trim-prefix` and before `--title-case`; `--name` / `--names-file` overrides bypass it entirely. Longer substrings are removed before shorter ones, so e.g. `clone_18` is removed cleanly even when `clone_1` is also in the list |
| `--title-case` | `false` | Convert chart labels to space-separated title case, normalizing snake_case, kebab-case, PascalCase, camelCase, and SCREAMING_SNAKE (e.g. `belt_v2` → `Belt V2`, `BeltV2` → `Belt V2`). Applied after `--trim-prefix`; `--name` / `--names-file` overrides bypass it entirely |
| `--aggregate-file <path>` | `""` | Path to a run-results file for outlier filtering |
| `--stddev-filter <n>` | `3` | Remove runs outside N standard deviations from the mean (requires `--aggregate-file`) |
| `--title-override <string>` | *(auto)* | Override the chart's auto-generated title |
| `--subtitle <string>` | *(none)* | Draw this text smaller under the title (all chart commands except `table`), so run details such as ticks measured, runs, game version or allocator do not have to be appended to a long `--title-override`. The chart makes room for it |

> **Several inputs** — chart two sessions of the same saves (two allocators, game versions or machines) without symlinks or a temporary names file:
> ```bash
> belt-charts ups --input "results_malloc/*.csv:malloc" --input "results_mimalloc/*.csv:mimalloc" -o charts/ups.png
> # rows: "4 Inserters, As Saved (malloc)", "4 Inserters, As Saved (mimalloc)", ...
> ```
> The suffix is whatever follows the last `:` of the argument (a Windows drive letter such as `C:\data\*.csv` is not mistaken for one). `--names-file` and `--name` keys still refer to the base name without the suffix. `--aggregate-file` run filters are matched by base name, so they apply to every input that has that file name. `bar` / `line` write one image per input file; the suffix is added to each file name (`timeseries_<name>_<suffix>.png`).
>
> `--include` / `--exclude` patterns are matched (shell-glob style, `*` and `?`) against the file's base name, its label, and its label with the suffix, e.g. `--exclude "*(mimalloc)"`.
>
> **Label pipeline** — transforms are applied in this order: `--name`/`--names-file` → `--trim-prefix` → `--trim-substring` → `--title-case`. If a `--name` match is found the custom label is used as-is and all remaining steps are skipped.
>
> **Auto-sizing** — `-w`/`-h` are a floor, not a fixed size, for charts whose content could otherwise be squished illegibly: `summary`, `summary-per-run`, `entity-summary`, and `entity-summary-per-run` grow **height** to fit every bar row plus the in-chart table (when enabled) and grow **width** to fit the in-chart table's columns; `boxplot` grows **width** to fit every category column; `entity-matrix` grows **height**; `entity-heatmap` and `core-freq-heatmap` grow both **width and height** to fit their grid. Charts that already have enough room are unaffected. `bar`/`line` never grow beyond the requested size, since their x-axis is continuous time rather than a discrete category count.
>
> **High-resolution output** — `-w`/`-h` set the *layout* size (font sizes, margins, and label placement are laid out against it). `--scale N` then renders that same layout at N× the pixel count, so text and lines stay sharp instead of shrinking. Final image size is `(width × N) × (height × N)`, applied after auto-sizing. e.g. `-w 1000 -h 800 --scale 2` produces a 2000×1600 PNG that looks identical to the 1000×800 one, just crisper:
> ```bash
> belt-charts summary "results/*.csv" -o charts/summary.png -w 1000 -h 800 --scale 2
> ```
>
> `--title-case` recognises snake_case (`_`), kebab-case (`-`), PascalCase, camelCase, and SCREAMING_SNAKE — all produce the same space-separated title case output:
>
> | Input | Output |
> |---|---|
> | `belt_v2` | `Belt V2` |
> | `belt-v2` | `Belt V2` |
> | `BeltV2` | `Belt V2` |
> | `beltV2` | `Belt V2` |
> | `BELT_V2` | `Belt V2` |
>
> Example with `--trim-prefix "my_map_" --trim-substring "clone_1" --title-case`:
> ```
> my_map_belt_v2_clone_1_verbose_metrics.csv
>   → base name       : my_map_belt_v2_clone_1
>   → trim prefix     : belt_v2_clone_1
>   → trim substrings : belt_v2_
>   → title case      : Belt V2
> ```
> Adding `--name "my_map_belt_v2_clone_1=Belt Design v2"` bypasses all transforms and uses `Belt Design v2` directly.

### Animated Video Output

`summary`, `summary-per-run`, `ups`, `ups-per-run`, `entity-summary`, `entity-summary-per-run`, `boxplot`, `line`, and `bar` support rendering an animated MP4 instead of a static image, useful for presentations. Bars/boxplots grow in from 0; `line`/`bar` time-series draw on progressively left-to-right. Encoding uses a bundled ffmpeg binary — no separate ffmpeg install required.

| Option | Default | Description |
|---|---|---|
| `--animate` | `false` | Render an animated MP4 instead of a static image. Requires `-o/--output` to end in `.mp4` |
| `--duration <seconds>` | `3` | Animation duration in seconds |
| `--fps <number>` | `30` | Animation frame rate |
| `--easing <linear\|ease-out\|ease-in-out>` | `ease-out` | Animation easing curve |
| `--hold <seconds>` | `1` | Extra seconds to hold the final frame at the end of the animation |
| `--stagger` | `false` | `summary`/`summary-per-run`/`ups`/`ups-per-run`/`entity-summary`/`entity-summary-per-run` only. Animate each bar's grow-in staggered by row (one save file/run at a time) instead of all bars growing together |

```
belt-charts summary "results/my_amazing_map*.csv"
  --animate
  -o "charts/all_metrics.mp4"
  --duration 4
  --fps 30
  --easing ease-out
  --hold 1.5
  --stagger
```

---

### Value Labels

`summary`, `summary-per-run`, `ups`, `ups-per-run`, `entity-summary`, and `entity-summary-per-run` support printing each stacked bar segment's value directly on the bar.

| Option | Default | Description |
|---|---|---|
| `--value-labels` | `false` | Print each stacked segment's value on the bar. Segments too narrow to legibly fit their label are skipped |

```
belt-charts summary "results/my_amazing_map*.csv"
  -o "charts/all_metrics.png"
  --value-labels
```

---

### Row Order

`summary`, `ups`, `entity-summary` and `boxplot` order their rows by total time, so the same save lands in a different row from one chart to the next. `--sort` keeps a fixed order instead.

| Option | Default | Description |
|---|---|---|
| `--sort <total\|input\|name>` | `total` | `total`: ranked by total time (today's behaviour; `boxplot` ranks by mean, slowest first). `input`: the order of the `--include` patterns (saves matched by the same pattern follow the names file), then of the names file (and `--name` flags), then of the inputs (sorted by file name within each input); sessions of the same save stay next to each other. `name`: by the label shown in the chart, numbers compared as numbers. With `--group-by` the same order applies inside each group |

When the rows are not ordered by total, the `vs Best` column still measures against the fastest row, and `vs Prev` against the row above. With `--group-by` the comparisons stay inside each group: `vs Prev` (`+/- vs Previous` for `ups`) is empty on the first row of a group and otherwise compares with the row above it, `vs Best` compares with the best row of the group, and `Overlaps Prev` (with `--error-bars`) follows the same rule.

```
# Three charts over different subsets show the saves in the same order as the names file
belt-charts ups "results/*.csv" --names-file names.txt --sort input --include "4i-*" -o charts/ups_4i.png
belt-charts ups "results/*.csv" --names-file names.txt --sort input --include "*shuffled" -o charts/ups_shuffled.png
```

---

### Difference Against a Baseline

`summary`, `ups` and `entity-summary` can draw differences instead of absolute values, so a claim such as "memory order saves 86-97 µs of inserter time" comes straight from the chart.

| Option | Default | Description |
|---|---|---|
| `--baseline <label>` | *(none)* | The row everything is compared against, named by its label (as shown in the chart, including any `--input` suffix) or its base name. Each segment is drawn as its change against the same segment of the baseline row, diverging from zero (µs; for `ups`, updates per second). The baseline row is marked `(baseline)` and is empty. It must match exactly one row; with `--group-by` it is looked up inside each group |
| `--baseline-per-group <key=label,...>` | *(none)* | With `--group-by`: the baseline of each group, e.g. `"q1=Q1 As Saved,q2=Q2 As Saved"`. Takes precedence over `--baseline` for the listed groups. Labels cannot contain commas |

The in-chart table and the exported `.csv`/`.md` show the same changes instead of absolute values: `summary` gets `Δ <segment>` columns, `Δ Whole %` and the absolute `Whole`; `entity-summary` gets `Δ <segment>` columns, `Δ Entity Update`, `Δ Entity Update %` and the absolute total; `ups` keeps `UPS` and adds `+/- vs Baseline` and `% vs Baseline`. Rows are ordered as usual (see Row Order); `--baseline` does not reorder them.

```
belt-charts entity-summary "results/*.csv" --baseline "4i-as-saved" --value-labels -o charts/inserter_delta.png
belt-charts summary "results/*.csv" --group-by "q1,q2" --baseline-per-group "q1=q1_as_saved,q2=q2_as_saved" -o charts/delta_by_group.png
```

---

### Error Bars

`summary`, `ups` and `entity-summary` can show how much a total varies from run to run, so claims like "these two builds can't be told apart" or "the gap is about 1%" can be read off the chart. The spread is computed from the **per-run means** of the total (each run's average over its ticks), not from individual ticks.

| Option | Default | Description |
|---|---|---|
| `--error-bars <stddev\|ci95\|minmax>` | *(off)* | `stddev`: ± the sample standard deviation (n − 1) of the run means. `ci95`: ± the 95% confidence interval of their mean (Student's t). `minmax`: from the smallest to the largest run mean. Drawn on the end of each bar (the whole update; the entity update for `entity-summary`; updates per second for `ups`) |

The table and the exported `.csv`/`.md` gain the spread (`± Std Dev`, `± 95% CI`, or `Min Run` and `Max Run`) and an `Overlaps Prev` column: `yes` when the row's interval overlaps the row above, i.e. the two cannot be told apart within run-to-run noise. A file with a single run has no `stddev` / `ci95` bar. Not available with `--baseline`, nor on the `-per-run` commands.

```
belt-charts ups "results/*.csv" --error-bars ci95 -o charts/ups.png
```

---

### Paired Bars for Two Sessions

Two sessions of the same saves (allocator, game version, machine) double the row count: 12 saves in two sessions make a 24-row chart. `--paired` draws one row per save instead, with one bar per session side by side. The session is the label suffix of its `--input`; the save is the label without that suffix.

`summary`, `ups` and `entity-summary` support it.

| Option | Default | Description |
|---|---|---|
| `--paired` | `false` | One row per save with one bar per session (stacked bars side by side for `summary` and `entity-summary`, one colored bar per session for `ups`). Needs at least two `--input "<glob>:<suffix>"`. Each bar is named with its session, and the legend lists the sessions. A save that is missing from a session just has no bar there. Rows are ranked by the first session (`--sort` applies, and so does `--group-by`). Not combined with `--baseline` or `--error-bars` |

The table has one row per save: each session's total, then the change of every later session against the first (`+/- <session> vs <first>` and `% <session> vs <first>`).

```
belt-charts ups --input "results_malloc/*.csv:malloc" --input "results_mimalloc/*.csv:mimalloc" --paired --names-file names.txt -o charts/ups_paired.png
```

---

### `summary`

Stacked-bar chart aggregating all metrics across input files, with an optional in-chart table.

| Option | Default | Description |
|---|---|---|
| `-a, --aggregate-strategy` | `average` | How to aggregate ticks per run: `average`, `minimum`, `maximum`, `median`, `standard_deviation` |
| `--summary-table <bool>` | `true` | Render a stats table inside the chart |
| `--summary-table-file <bool>` | `true` | Export the table as `.csv` and `.md` alongside the chart |
| `--max-update <number>` | *(auto)* | Fix the maximum x-axis value (microseconds). Useful for comparing charts at a consistent scale |
| `--group-by <keys>` | *(none)* | Comma-separated list of group keys (e.g. `clone_0,clone_1,clone_18`). Each result is assigned to the longest key that is a substring of its **original** file base name (the file name without `.csv` or `_verbose_metrics`) — matching happens before any label transforms, so `--trim-substring` and `--title-case` cannot break group assignment, and a label from `--names-file` or `--name` is not matched. A key that matches no input file prints a warning, and so does a grouping that leaves no rows. Results that don't match any key are excluded. Matched results are clustered under bold group-header rows in the chart and table, sorted by key order. Write an entry as `key=Label` to show `Label` instead of the key in the group headers and the table's Group column, e.g. `"3i-2to1=3 Inserters 2:1,3i-3to1=3 Inserters 3:1,4i=4 Inserters"`; entries without `=` show the key. Matching always uses the key, `--baseline-per-group` takes keys, and `--names-file` / `--name` entries do not apply to groups. Labels cannot contain commas |
| `--allow-unfiltered-metrics` | `false` | **Advanced / opt-in.** Bypass the built-in `MetricProfiles.SUMMARY_CHART` filter so any metric passed via `--metrics` is rendered, even metrics outside the default profile. **Warning:** dataset ordering, legend ordering, and pattern/color assignment are tuned for the default profile; off-profile metrics may render or lay out unexpectedly. A warning is printed at run time |

> **Why is there a metric profile in the first place?** The fixed profile is deliberate. belt-charts assigns a **stable, color-blind-friendly color to each metric** (e.g. `entityUpdate` is always the same blue everyone recognises at a glance), and non-color-blind-friendly hues are backed by distinguishing **pattern fills** so the chart still reads unambiguously in grayscale or for readers with color-vision deficiencies. Both the palette and the pattern set are only defined for metrics in the default profile — off-profile metrics fall back to whatever the underlying chart library picks, which may collide with other metrics' colors or lose their pattern. `--allow-unfiltered-metrics` intentionally opts out of that guarantee.

```
belt-charts summary "results/my_amazing_map*.csv"
  -w 1500 -h 800
  --remove-first-ticks 30
  -o "charts/all_metrics.png"
  -a average
  --metrics "wholeUpdate,entityUpdate,controlBehaviorUpdate,transportLinesUpdate,electricHeatFluidCircuitUpdate"
  --summary-table true
  --summary-table-file true
  --trim-prefix "my_amazing_map_"
  --name "my_amazing_map_a=Design A"
  --name "my_amazing_map_b=Design B"
  --min-percent 1
```

**`--group-by` example** — benchmarks run across three clone counts, trim the clone tag from labels, cluster results by clone:

```
belt-charts summary "results/bm_*_clone_*.csv"
  -w 1400 -h 900
  --remove-first-ticks 3600
  -o "charts/by_clone.png"
  -a median
  --trim-prefix "bm_"
  --trim-substring "clone_0"
  --trim-substring "clone_1"
  --trim-substring "clone_18"
  --title-case true
  --group-by "clone_0,clone_1,clone_18"
  --summary-table-file true
```

The `--group-by` keys are matched against the original file base name (before any trim or title-case transforms), so `clone_0`, `clone_1`, and `clone_18` are still found in the name even though `--trim-substring` will later strip them from the visible label. Longest-match means `clone_18` files are correctly assigned to the `clone_18` group, not the `clone_1` group. When `--summary-table-file` is active the exported `.md`/`.csv` gains a **Group** column as its first column.

To give the groups readable headings, add a label after the key: `--group-by "clone_0=No clones,clone_1=1 clone,clone_18=18 clones"`. The headings in the chart and the **Group** column then show the labels.

---

### `summary-per-run`

Same as `summary` but shows one bar per individual run instead of averaging across runs.

| Option | Default | Description |
|---|---|---|
| `-a, --aggregate-strategy` | `average` | Per-run statistic to display (`average`, `minimum`, `maximum`, `median`, `standard_deviation`) |
| `--summary-table <bool>` | `true` | Render a stats table inside the chart |
| `--summary-table-file <bool>` | `true` | Export the table as `.csv` and `.md` |
| `--sort-by <run\|total>` | `total` | Sort bars by run number or by total `wholeUpdate` time |
| `--allow-unfiltered-metrics` | `false` | **Advanced / opt-in.** Same as on `summary` — bypass the built-in metric-profile filter so any `--metrics` value is rendered. Emits a warning at run time |

```
belt-charts summary-per-run "results/my_amazing_map*.csv"
  -w 2000 -h 1000
  --remove-first-ticks 30
  -o "charts/per_run_metrics.png"
  -a average
  --sort-by total
  --summary-table true
  --summary-table-file true
  --trim-prefix "my_amazing_map_"
```

---

### `ups`

Same as `summary`, but renders a single bar per save file showing updates per second (UPS) — computed as `1,000,000 / wholeUpdate` (microseconds) — instead of the stacked per-component time breakdown.

| Option | Default | Description |
|---|---|---|
| `-a, --aggregate-strategy` | `average` | How to aggregate ticks per run: `average`, `minimum`, `maximum`, `median`, `standard_deviation` |
| `--summary-table <bool>` | `true` | Render a stats table inside the chart |
| `--summary-table-file <bool>` | `true` | Export the table as `.csv` and `.md` alongside the chart |
| `--group-by <keys>` | *(none)* | Same as `summary`'s `--group-by` |

```
belt-charts ups "results/my_amazing_map*.csv"
  -w 1200 -h 600
  --remove-first-ticks 30
  -o "charts/ups.png"
  --trim-prefix "my_amazing_map_"
```

---

### `ups-per-run`

Same as `ups` but shows one bar per individual run instead of averaging across runs.

| Option | Default | Description |
|---|---|---|
| `-a, --aggregate-strategy` | `average` | Per-run statistic to display (`average`, `minimum`, `maximum`, `median`, `standard_deviation`) |
| `--summary-table <bool>` | `true` | Render a stats table inside the chart |
| `--summary-table-file <bool>` | `true` | Export the table as `.csv` and `.md` |
| `--sort-by <run\|total>` | `total` | Sort bars by run number or by UPS |

```
belt-charts ups-per-run "results/my_amazing_map*.csv"
  -w 1200 -h 800
  --remove-first-ticks 30
  -o "charts/ups_per_run.png"
  --sort-by total
```

---

### `bar` / `line`

Timeseries charts — one output file per input CSV. `bar` renders stacked areas; `line` renders lines.

| Option | Default | Description |
|---|---|---|
| `-a, --aggregate-strategy` | `average` | How to aggregate runs per tick |
| `--tick-window-aggregation <n>` | `0` | Time-weighted average over a rolling window of N ticks. `0` = no windowing |
| `--max-update <number>` | *(auto)* | Y-axis ceiling in µs. Auto-detected from data if omitted |
| `--allow-unfiltered-metrics` | `false` | **Advanced / opt-in.** Bypass the built-in metric-profile filter so any `--metrics` value is rendered, even metrics outside the default line-chart profile. Emits a warning at run time |

> When any PascalCase entity metric (e.g. `Inserter`, `AssemblingMachine`) is included in `--metrics`, `entityUpdate` is automatically excluded from the stacked areas and becomes the "Total Entity Update Average" reference line instead of "Whole Update Average".

```
belt-charts bar "results/my_amazing_map*.csv"
  -w 1200 -h 800
  --remove-first-ticks 30
  -o "charts/timeseries.png"
  -a average
  --max-ticks 18000
  --max-update 3000
  --trim-prefix "my_amazing_map_"
  --metrics "wholeUpdate,controlBehaviorUpdate,transportLinesUpdate,electricHeatFluidCircuitUpdate,entityUpdate"
  --tick-window-aggregation 60
```

---

### `boxplot`

Box-and-whisker chart showing the distribution of `wholeUpdate` across all runs per file.

| Option | Default | Description |
|---|---|---|
| `--min-update <number>` | *(auto)* | Y-axis floor in µs |
| `--max-update <number>` | *(auto)* | Y-axis ceiling in µs |

```
belt-charts boxplot "results/my_amazing_map*.csv"
  -w 1000 -h 800
  --remove-first-ticks 30
  -o "charts/run_distribution.png"
  --trim-prefix "my_amazing_map_"
```

---

### `table`

Exports aggregate statistics to `.csv` and `.md` without generating a chart image.

| Option | Default | Description |
|---|---|---|
| `-a, --aggregate-strategy` | `average` | How to aggregate runs |

```
belt-charts table "results/my_amazing_map*.csv"
  --remove-first-ticks 30
  -o "charts/stats.csv"
  -a average
  --trim-prefix "my_amazing_map_"
```

---

### `prune`

Shrinks results files without changing any chart: verbose metrics files run to tens of MB a save, and most of the 100+ columns are zero in every file. `prune` drops the columns that are zero in **every** file of the set (so every pruned file has the identical header) and can compress the result. A dropped column reads as zero, exactly as before, so the exported tables and images are unchanged.

| Option | Default | Description |
|---|---|---|
| `<glob-pattern>` | *(required)* | Results files to prune (`.csv`, `.csv.gz`, `.csv.zst`) |
| `--out-dir <dir>` | *(none)* | Write the pruned files to this directory; the originals stay |
| `--in-place` | `false` | Replace the files where they are (a file that changes its name, e.g. by compressing, is replaced by the new one). One of `--out-dir` and `--in-place` is required, so nothing is overwritten by accident |
| `--keep-only-charted` | `false` | Also drop columns no chart command reads. Kept: `tick`, `run`, `wholeUpdate`, the summary categories, `entityUpdate` and every entity type. `line` / `bar` with `--metrics` naming another column, or `table` (which exports every metric), would no longer find it |
| `--compress <gz\|zst\|none>` | *(as the input)* | Write `.csv.gz`, `.csv.zst` or plain `.csv` |
| `--dry-run` | `false` | Only report which columns would be dropped |

`tick`, `run` and `wholeUpdate` are always kept. Files are streamed, so memory use stays flat however large they are.

Every command reads `.csv.gz` and `.csv.zst` transparently, so a compressed folder charts like the original (`belt-charts summary "results/*.csv.gz"`; labels and `--names-file` keys use the base name without the extension). Reading and writing `.zst` uses Node's built-in zstd support, which needs **Node.js 22.15 or newer** (gzip works everywhere).

```
belt-charts prune "results/*.csv" --keep-only-charted --compress zst --out-dir results_small
belt-charts summary "results_small/*.csv.zst" -o charts/summary.png
```

---

### `render`

Renders a whole chart set from one JSON config file, so a benchmark's width, height, scale, trim, names file and aggregation are written once instead of on every command line.

```
belt-charts render charts.json
belt-charts render charts.json --dry-run   # print the command line of every chart without rendering
```

```json
{
  "defaults": {
    "width": 1400,
    "scale": 2,
    "removeFirstTicks": 1500,
    "namesFile": "names.txt",
    "subtitle": "Game 2.0.76, 15000 ticks measured, 10 runs"
  },
  "charts": [
    { "command": "ups", "input": "results/*.csv", "output": "charts/ups.png", "sort": "input" },
    { "command": "entity-summary", "input": "results/*.csv", "output": "charts/entity.png", "valueLabels": true },
    {
      "command": "summary",
      "input": ["malloc/*.csv:malloc", { "path": "mimalloc/*.csv", "suffix": "mimalloc" }],
      "output": "charts/by_allocator.png",
      "paired": true,
      "metrics": ["wholeUpdate", "entityUpdate"]
    }
  ]
}
```

- `defaults` apply to every chart whose command has that option (the others skip it); a chart's own value wins.
- Each chart names its `command` (any chart command: `summary`, `ups`, `entity-summary`, `boxplot`, `line`, `bar`, `table`, ...), its `input` (a glob, or a list of globs; `"<glob>:<suffix>"` or `{ "path": ..., "suffix": ... }` for a label suffix) and its `output`. Any other key is a long option of that command, written camelCase (`removeFirstTicks`) or kebab-case (`remove-first-ticks`).
- Flags take `true` / `false`; options that take a list (`metrics`, `groupBy`, ...) take a JSON array; repeatable options (`include`, `exclude`, `trimSubstring`) take an array too; `name` takes an object `{ "base_name": "Label" }`.
- Paths (`input`, `output`, `namesFile`, `aggregateFile`) are resolved relative to the config file, so it works from any directory. Absolute paths are kept.
- Charts are rendered one after another; an unknown option or a missing file stops the run with a message naming the chart. Only JSON is supported (no YAML, no comments).

---

### `entity-summary`

Stacked-bar chart decomposing `entityUpdate` into per-entity-type contributions. Requires Factorio verbose metrics CSVs that include the PascalCase per-entity columns (e.g. `Inserter`, `AssemblingMachine`).

| Option | Default | Description |
|---|---|---|
| `-a, --aggregate-strategy` | `average` | How to aggregate runs |
| `--top-n <n>` | `15` | Show only the top N entity types; the rest fold into "Other Entity Update". `0` = show all |
| `--sort-by <run\|total>` | `total` | (`entity-summary-per-run` only) Sort bars by run number or by entityUpdate total |
| `--summary-table <bool>` | `true` | Render a stats table inside the chart |
| `--summary-table-file <bool>` | `true` | Export the table as `.csv` and `.md` |
| `--group-by <keys>` | *(none)* | Same behaviour as in `summary` — see above |

```
belt-charts entity-summary "results/my_amazing_map*.csv"
  -w 1600 -h 1000
  --remove-first-ticks 30
  -o "charts/entity_summary.png"
  -a average
  --top-n 15
  --min-percent 1
  --summary-table true
  --summary-table-file true
  --trim-prefix "my_amazing_map_"
```

---

### `entity-summary-per-run`

Same as `entity-summary` but shows one bar per individual run (no averaging across runs).

| Option | Default | Description |
|---|---|---|
| `-a, --aggregate-strategy` | `average` | Per-run statistic to display |
| `--top-n <n>` | `15` | Top N entity types |
| `--sort-by <run\|total>` | `total` | Sort bars by run number or entityUpdate total |
| `--summary-table <bool>` | `true` | Render a stats table inside the chart |
| `--summary-table-file <bool>` | `true` | Export the table as `.csv` and `.md` |

```
belt-charts entity-summary-per-run "results/my_amazing_map*.csv"
  -w 1600 -h 1000
  --remove-first-ticks 30
  -o "charts/entity_summary_per_run.png"
  -a average
  --top-n 15
  --sort-by run
  --min-percent 1
  --summary-table true
  --summary-table-file true
  --trim-prefix "my_amazing_map_"
```

---

### `entity-matrix`

Panel chart — rows = entity types, columns = benchmark files, cells = horizontal bar scaled to a shared x-axis. Good for comparing the same entity type across many designs at a glance.

| Option | Default | Description |
|---|---|---|
| `-a, --aggregate-strategy` | `average` | How to aggregate runs |
| `--top-n <n>` | `15` | Show only the top N entity types |

```
belt-charts entity-matrix "results/my_amazing_map*.csv"
  -w 1400 -h 800
  --remove-first-ticks 30
  -o "charts/entity_matrix.png"
  -a average
  --top-n 15
  --min-percent 1
  --trim-prefix "my_amazing_map_"
```

---

### `entity-heatmap`

2-D heatmap — rows = entity types, columns = benchmark files, cells colored by µs intensity using a viridis-style gradient.

| Option | Default | Description |
|---|---|---|
| `-a, --aggregate-strategy` | `average` | How to aggregate runs |
| `--top-n <n>` | `20` | Show only the top N entity types |
| `--normalize <global\|column\|row>` | `global` | Color scale normalization. `global` = single scale for all cells (best for spotting the absolute hottest cell); `column` = per-design scale (best for comparing entity profiles within one design); `row` = per-entity scale (best for spotting which design stresses a particular entity the most) |
| `--show-values <bool>` | `true` | Render µs values inside each cell |

```
belt-charts entity-heatmap "results/my_amazing_map*.csv"
  -w 1400 -h 900
  --remove-first-ticks 30
  -o "charts/entity_heatmap_global.png"
  -a average
  --top-n 20
  --min-percent 1
  --normalize global
  --show-values true
  --trim-prefix "my_amazing_map_"
```

---

### `core-freq-heatmap`

2-D heatmap of per-core CPU frequency samples from a `cpu_freq.csv` sidecar file (columns: `save_name, run_index, core_index, cpu_frequency, timestamp`). Rows = one per run (grouped by benchmark, since a single `cpu_freq.csv` can bundle multiple `save_name`s), columns = core index. Useful for spotting whether a run got assigned a relatively "hot" or "cold" core, without needing to pin cores.

| Option | Default | Description |
|---|---|---|
| `-a, --aggregate-strategy <average\|minimum\|maximum\|median\|standard_deviation>` | `average` | Which per-core statistic to display/color |
| `--normalize <global\|column\|row>` | `column` | Color scale normalization. `global` = single scale for all cells; `column` = per-core scale (best for spotting systematic hardware differences between cores); `row` = per-run scale (best for spotting which core stood out within a single run) |
| `--show-values <bool>` | `true` | Render MHz values inside each cell |
| `--save-name-filter <glob>` | *(none)* | Glob pattern to filter which `save_name` values are included (repeatable, OR-matched). Matches against the `save_name` column value itself, not a file path — e.g. `--save-name-filter "foo*"`. Unmatched patterns are unfiltered (all save_names included) by default |

```
belt-charts core-freq-heatmap "results/cpu_freq.csv"
  -w 1600 -h 1000
  -o "charts/core_freq_heatmap.png"
  -a average
  --normalize column
  --show-values true
  --save-name-filter "ship_benchmark_50_*"
```

---

## SVG Export

All chart commands support SVG output in addition to PNG. The format is inferred from the `--output` file extension — simply use `.svg` instead of `.png`:

```bash
belt-charts summary "results/*.csv" -o "charts/summary.svg" ...
belt-charts boxplot "results/*.csv" -o "charts/boxplot.svg" ...
belt-charts bar "results/*.csv" -o "charts/timeseries.svg" ...
```

SVG files are rendered using [skia-canvas](https://github.com/samizdatco/skia-canvas)'s native vector backend, producing true vector output rather than an embedded bitmap. This makes them resolution-independent and suitable for embedding in reports or web pages.

For `line` and `bar` commands (which generate one file per input CSV), the extension is preserved per-file:

```bash
# Input: results/map_a.csv, results/map_b.csv
# Output: charts/timeseries_map_a.svg, charts/timeseries_map_b.svg
belt-charts bar "results/*.csv" -o "charts/timeseries.svg" ...
```

PNG is the default when no extension is specified or when `.png` is used.

## Requirements

- Node.js >= 14.0.0 (reading and writing `.csv.zst` needs Node.js >= 22.15)
- npm or yarn

## License

MIT

---
_Source: https://npm.io/package/belt-charts · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
