---
name: report-builder
description: >-
Build a self-contained single-page HTML report or dashboard from data with Python, Jinja2, Bootstrap 5 and Chart.js or Plotly. Use whenever the task is an HTML report, dashboard, metrics or status page, or "visualize this" for a CSV, DataFrame or JSON. Covers safe Jinja2 autoescaping, passing data to JS with tojson, choosing Chart.js or Plotly, and shipping one portable file.
license: MIT
---
# Report Builder
The job is almost always the same shape: **data in → one HTML file out**, rendered by a
template, viewable by double-clicking with no server. Keep that shape and the work stays
small and reproducible. The two failure modes to design against are (1) non-determinism
(charts that fetch live, timestamps that drift) and (2) unsafe data interpolation (raw
values dropped into HTML or `, quotes, unicode #}
```
This is correct *and* XSS-safe. Building JS by concatenating values is the classic
injection hole — don't.
## Chart.js or Plotly — pick per report
| Use **Chart.js** when | Use **Plotly** when |
|---|---|
| Standard charts: bar, line, pie, doughnut, radar | Interactive exploration: zoom, pan, rich hover, selection |
| Small bundle, fast, dashboard-y look | Statistical/scientific: box, violin, heatmap, 3D, contour |
| Few hundred → few thousand points | Large datasets, or users will drill into the data |
| You want a clean default aesthetic with little config | You need subplots, dual axes, or precise scientific layout |
Default to **Chart.js** for status/metrics dashboards; reach for **Plotly** when the reader
needs to *interrogate* the data, not just read it. Don't load both unless a report truly
needs each.
## Self-contained vs. CDN
- **CDN** (default for internal/online reports): Bootstrap 5, Chart.js, Plotly via
`