Skip to content

Validate discrete chartProperties values; docs show accepted values not labels#52

Merged
Chenglong-MS merged 3 commits into
devfrom
copilot/fix-vega-lite-regression-issue
Jul 12, 2026
Merged

Validate discrete chartProperties values; docs show accepted values not labels#52
Chenglong-MS merged 3 commits into
devfrom
copilot/fix-vega-lite-regression-issue

Conversation

Copilot AI commented Jul 11, 2026

Copy link
Copy Markdown

Following the generated Vega-Lite reference docs for the Regression template rendered a blank chart: the docs' Domain column listed option labels (Logarithmic) instead of accepted values (log), and the assembler copied the unrecognized value verbatim into the Vega-Lite regression transform, which the renderer silently rejects.

assembleVegaLite({
  /* … */
  chart_spec: { chartType: "Regression",
    encodings: { x: { field: "flops" }, y: { field: "loss" } },
    chartProperties: { regressionMethod: "Logarithmic" } },  // label copied from docs
});
// before → "method": "Logarithmic"  (invalid; blank chart)
// after  → "method": "log"          (+ info warning about the coercion)

Changes

  • core/normalize-properties.ts (new) — validates discrete chartProperties against the template's declared options before instantiate:
    • valid value → passthrough
    • known label (case-insensitive) → mapped to its value, info warning
    • unrecognized value → dropped so the property falls back to its default, warning (preserves the "safe to pass" contract instead of emitting an invalid backend spec)
  • Assemblers — wired the normalization into all three backends (Vega-Lite, ECharts, Chart.js), so the class of bug can't recur per-backend.
  • scripts/gen-chart-reference.ts — discrete Domain/Default columns now render the accepted value in code font with the label as secondary text (e.g. `log` (Logarithmic)); options with an undefined value render as Label _(default)_. Regenerated docs/reference-*.md.
  • Teststests/chart-properties-validation.test.ts covers valid value, label coercion, case-insensitivity, invalid-value drop, and default.

Note for reviewers

An unrecognized value is dropped-to-default with a warning rather than throwing, matching the docs' "non-applicable parameters are safe to pass" wording. Switching to a hard error is a one-line change in normalize-properties.ts if preferred.

Copilot AI changed the title [WIP] Fix Vega-Lite regression for invalid option values Validate discrete chartProperties values; docs show accepted values not labels Jul 11, 2026
Copilot AI requested a review from Chenglong-MS July 11, 2026 17:17
@Chenglong-MS Chenglong-MS changed the base branch from main to dev July 12, 2026 06:20
@Chenglong-MS Chenglong-MS marked this pull request as ready for review July 12, 2026 06:21
@Chenglong-MS Chenglong-MS merged commit 40ce81b into dev Jul 12, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vega-Lite Regression: docs list option labels as the Domain, and the assembler passes the invalid value through — chart renders blank

2 participants