#[non_exhaustive]pub struct Theme {Show 39 fields
pub text: String,
pub text_secondary: String,
pub text_strong: String,
pub axis_line: String,
pub tick: String,
pub grid: String,
pub bg: String,
pub title_font_family: String,
pub title_font_size: f32,
pub title_font_weight: u16,
pub title_font_style: String,
pub label_font_family: String,
pub label_font_size: f32,
pub label_font_weight: u16,
pub label_letter_spacing: f32,
pub label_text_transform: TextTransform,
pub numeric_font_family: String,
pub numeric_font_size: f32,
pub legend_font_family: String,
pub legend_font_size: f32,
pub legend_font_weight: u16,
pub axis_line_weight: f32,
pub grid_line_weight: f32,
pub series_line_weight: f32,
pub annotation_line_weight: f32,
pub bar_corner_radius: BarCornerRadius,
pub dot_radius: f32,
pub dot_halo_color: Option<String>,
pub dot_halo_width: f32,
pub grid_style: GridStyle,
pub zero_line: Option<ZeroLineSpec>,
pub table_header_bg: String,
pub table_header_text: String,
pub table_row_bg: String,
pub table_row_bg_alt: String,
pub table_border: String,
pub table_text: String,
pub table_cell_padding: String,
pub table_font_size: String,
}Expand description
Chart theme — colors, typography, and shape defaults.
Color fields are CSS color strings (typically hex like "#374151") that
are written directly into SVG stroke and fill attributes.
§Line weight audit (Phase 2)
Defaults for the stroke-weight fields were chosen by auditing every
hardcoded stroke_width: Some(X.0) across the renderer crates and
categorizing each by role. The audit found:
- axis_line_weight = 1.0 — universal across
chartml-chart-cartesian/src/helpers.rs(lines 419, 684, 756, 866, 957) andchartml-chart-scatter/src/lib.rs(lines 237, 242). All axis lines currently use 1.0. (Tick marks also use 1.0 today and reuse this field.) - grid_line_weight = 1.0 — universal across
chartml-chart-cartesian/src/helpers.rs(lines 434, 780, 982) andchartml-chart-scatter/src/lib.rs(lines 168, 211). - series_line_weight = 2.0 — majority value in
chartml-chart-cartesian/src/{line.rs:454, 563, 635},area.rs:{212, 343, 481}, andbar.rs:1258(combo line). Outlier: legend line symbols use 2.5 inbar.rs:1352andchartml-core/src/layout/legend.rs:220— this is a legend-specific glyph weight, not a series weight, and is intentionally not folded in. NOT included:chartml-chart-pie/src/lib.rs:75(pie slice border). The pie slice border usestheme.bgas its color — it is a background-colored separator gap between slices, not a series mark, and must NOT be wired toseries_line_weightin later phases. - annotation_line_weight = 1.0 — annotations currently read their
stroke width from the spec (
ann.stroke_widthinhelpers.rs:1348, 1382); no hardcoded default exists. 1.0 is chosen as the natural fallback for a future “annotation default” path (reference lines, brackets, etc.). - bar_corner_radius = BarCornerRadius::Uniform(0.0) — default is no
rounding (byte-identical to pre-3.1 behavior).
Uniform(r)rounds all four corners;Top(r)rounds only the two corners at the max-value end of the bar (seeBarCornerRadiusdocs). - dot_radius = 5.0 — matches
chartml-chart-scatter/src/lib.rs:106(default when no size field) and line endpoint markers inchartml-chart-cartesian/src/line.rs:{466, 577, 649}andbar.rs:1268(combo line dots).
§Construction contract
Theme is #[non_exhaustive]: external crates cannot construct it with
a struct literal or the functional-update spread syntax. They must start
from Theme::default() (or Theme::dark()) and mutate fields:
let mut theme = Theme::default();
theme.axis_line = "#9ca3af".into();
theme.grid = "#374151".into();This makes adding new fields genuinely non-breaking forever — every
downstream consumer that follows the mutate-after-default pattern keeps
compiling regardless of how many fields land in Theme later.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.text: StringPrimary text color (metric values, param controls).
text_secondary: StringSecondary text color (tick labels, axis labels, legend labels).
text_strong: StringStrong/emphasized text color (chart titles).
axis_line: StringAxis line strokes (the main horizontal/vertical axis lines).
tick: StringTick mark strokes (small marks at each tick position).
grid: StringGrid line strokes.
bg: StringBackground-aware stroke for element separators (pie slice borders, dot outlines). Should match the chart background.
title_font_family: StringFont family for chart titles.
title_font_size: f32Font size (px) for chart titles.
title_font_weight: u16Font weight for chart titles.
title_font_style: StringFont style ("normal" / "italic") for chart titles.
label_font_family: StringFont family for tick and axis labels.
label_font_size: f32Font size (px) for tick and axis labels.
label_font_weight: u16Font weight for tick and axis labels.
label_letter_spacing: f32Extra letter spacing (px) applied to labels.
label_text_transform: TextTransformText transform applied to labels.
numeric_font_family: StringFont family for numeric tick labels (e.g. a tabular/monospaced face).
numeric_font_size: f32Font size (px) for numeric tick labels.
legend_font_family: StringFont family for legend labels.
legend_font_size: f32Font size (px) for legend labels.
legend_font_weight: u16Font weight for legend labels.
axis_line_weight: f32Stroke width for axis lines. See audit in struct-level doc.
grid_line_weight: f32Stroke width for grid lines. See audit in struct-level doc.
series_line_weight: f32Stroke width for series marks (line paths, area outlines, combo line).
Pie slice borders are NOT series marks — they use theme.bg as a
background-colored separator. See audit in struct-level doc.
annotation_line_weight: f32Stroke width for annotation lines (reference lines, brackets). See audit in struct-level doc.
bar_corner_radius: BarCornerRadiusCorner radius for bar rects. Supports uniform rounding (all four
corners) and top-only rounding (the two corners at the max-value end
of the bar). When the enclosed radius is 0.0, renderers MUST NOT
emit any rx/ry attribute and MUST emit a plain <rect> (to
preserve byte-identical output for un-themed charts).
dot_radius: f32Default radius (px) for scatter points and line endpoint markers.
dot_halo_color: Option<String>Optional halo/outline color for dots. When None, no halo is drawn.
dot_halo_width: f32Halo stroke width (px). Only used when dot_halo_color is Some.
grid_style: GridStyleWhich gridlines to draw (both, horizontal-only, vertical-only, none).
zero_line: Option<ZeroLineSpec>Optional emphasized zero line on the value axis. None = no zero line.
table_header_bg: StringBackground color for the table header row.
table_header_text: StringText color for the table header row.
table_row_bg: StringBackground color for a regular (non-striped) body row.
table_row_bg_alt: StringBackground color for the alternating zebra-striped body row.
table_border: StringBorder color between cells and between header/body.
table_text: StringText color for body cells.
table_cell_padding: StringCSS shorthand padding for body cells (e.g. "8px 12px").
table_font_size: StringCSS font size for table text (e.g. "13px").