Skip to content

charts: support a description on plots (metrics already have one) #2818

Description

@thedavidmeister

Ask

Support a description on a plot, so a chart can carry explanatory text alongside its title and subtitle.

Current state

Plots support title and subtitle, but not description.

crates/settings/src/chart.rs:12-24

const ALLOWED_PLOT_KEYS: [&str; 11] = [
    "inset", "margin", "margin-bottom", "margin-left", "margin-right",
    "margin-top", "marks", "subtitle", "title", "x", "y",
];

title / subtitle are parsed at chart.rs:372-373 (optional_string(plot_yaml, …)) and carried on PlotCfg (crates/settings/src/plot_source.rs:10-12). A description: key on a plot is silently dropped by sanitize_hash_with_keys(plot_hash, &ALLOWED_PLOT_KEYS) (chart.rs:215).

Note that metrics already have exactly this — ALLOWED_METRIC_KEYS includes "description" (chart.rs:51-58), parsed at chart.rs:861. So there is an established pattern to follow, and the inconsistency between metrics and plots is itself a small wart.

Suggested change

Mirror the metric handling for plots:

  1. Add "description" to ALLOWED_PLOT_KEYS.
  2. let description = optional_string(plot_yaml, "description"); alongside the existing title/subtitle reads, and pass it into the PlotCfg construction (chart.rs:~835).
  3. Add pub description: Option<String> to PlotCfg with the same #[serde(skip_serializing_if = "Option::is_none")] treatment as title/subtitle.
  4. Extend the existing round-trip test (chart.rs:~1780-1838) to assert a plot description parses and that unknown keys are still dropped.
  5. Surface it wherever title/subtitle are rendered in the chart UI.

Context

Split out of #446 ("Add titles for axes in charts"), which is closed as delivered — axis labels, plot titles and subtitles all parse with round-trip test coverage. In that thread @Siddharth2207 additionally asked for "title, subtitle, description"; description is the one part of that request that was never implemented, so it is tracked here rather than lost in a closed issue.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions