Appendix D — Chart Template Library
Copy a template, rename it, fill in the data-specific parts. Each template is a complete, working component with sensible defaults. Comments mark what to customise.
All templates inherit height:, group:, and color: from Components::Chart
automatically — see Appendix C for details.
D.1 — Line Chart
When to use: Time series, trends, continuous data, multiple series comparison.
|
|
D.2 — Stacked Bar Chart
When to use: Part-to-whole over time, cumulative comparison across categories.
|
|
D.3 — Grouped Bar Chart
When to use: Side-by-side comparison across categories.
|
|
D.4 — Horizontal Bar Chart
When to use: Category labels too long for vertical bars, ranking comparisons.
|
|
D.5 — Pie Chart
When to use: Part-to-whole composition, 5–8 categories.
|
|
D.6 — Donut Chart
When to use: Composition with a summary value in the centre.
|
|
D.7 — Scatter Chart
When to use: Correlation between two variables, distribution analysis.
|
|
D.8 — Calendar Heatmap
When to use: Daily data over time, activity patterns, seasonal analysis.
|
|
D.9 — Gauge Chart
When to use: Single value in context, KPI dashboards, threshold indicators.
|
|
D.10 — Mixed Chart (Bar + Line, Dual Axis)
When to use: Two related series with different scales or units — volumes and rates, absolute values and percentages.
|
|
D.11 — Using the Templates
Copy and rename
|
|
Change the class name and module path:
|
|
Customise
Update the props, palette, formatters, and build_series method. The comments
in each template mark the customisation points.
Reference
All base class props are available without any additional code:
|
|
D.12 — Template Data Shapes
Each template expects data in a specific shape. Services should return data in the shape the template expects — or a thin transformation in the component maps between them.
| Template | Expected data shape |
|---|---|
| Line | { "Series A" => [{ label:, value: }, ...] } |
| Stacked Bar | { "Series A" => [{ label:, value: }, ...] } |
| Grouped Bar | { "Series A" => [{ label:, value: }, ...] } |
| Horizontal Bar | [{ label:, value: }, ...] |
| Pie | [{ label:, value: }, ...] |
| Donut | [{ label:, value: }, ...] |
| Scatter | { "Series A" => [[x, y], ...] } |
| Calendar | [["YYYY-MM-DD", value], ...] |
| Gauge | Float (single value) |
| Mixed | { labels:, bars: [{ name:, values: }], lines: [...] } |