Skip to content

feat(chartjs): add Lollipop Chart template#59

Open
zl190 wants to merge 1 commit into
microsoft:devfrom
zl190:feat/chartjs-lollipop
Open

feat(chartjs): add Lollipop Chart template#59
zl190 wants to merge 1 commit into
microsoft:devfrom
zl190:feat/chartjs-lollipop

Conversation

@zl190

@zl190 zl190 commented Jul 18, 2026

Copy link
Copy Markdown

What

The Vega-Lite and ECharts backends ship a Lollipop template; Chart.js doesn't, so the same ChartAssemblyInput compiles on two backends and throws on the third:

Unknown Chart.js chart type: Lollipop Chart. Use cjsAllTemplateDefs to see available types.

This PR ports the template to the Chart.js backend, mirroring the ECharts implementation.

Implementation

Chart.js has no rule mark, so the stem is a bar dataset with barThickness: 1.5 (black, same as the ECharts stem) and the dot is a point-only line dataset (showLine: false) on the shared category scale. (A scatter dataset would require numeric {x, y} points instead of category labels.)

  • Horizontal transposition via indexAxis: 'y' when the category is on y
  • Color grouping: one dot dataset per group; the stem is filtered out of legend and tooltip
  • dotSize property on the same 6–16px visual scale as the ECharts template
  • Zero baseline from the semantic zero decision (stems grow from 0)
  • Registered in the Bar group, same position as ECharts

One behavior is mirrored deliberately: with a color grouping, the stem length is the per-category sum while dots sit at individual group values — this matches the ECharts template (verified: same input gives stem data [288, 298, 297] on both backends). If that's worth changing, it applies to both backends — happy to file it separately.

Verification

  • tests/lollipop-chartjs.test.ts — 8 cases: registry, stem/dot shape, zero baseline, transposition, color groups, legend/tooltip filters, dotSize mapping, 3-backend parity
  • Full suite: 431 + 50 passing, typecheck clean
  • docs/reference-chartjs.md regenerated via npm run gen:reference (21 chart types)
  • SKILL.md Chart.js coverage list updated (+ bundled asset synced, per server.test.ts)

Side-by-side render vs Vega-Lite and ECharts (same input), plus the horizontal + grouped variant:

Lollipop across Vega-Lite, ECharts, and the new Chart.js template

Note: #58 also touches SKILL.md (a different section); whichever lands second may need a trivial re-sync of the bundled asset.

🤖 Generated with Claude Code

Port the Lollipop template to the Chart.js backend, mirroring the
ECharts implementation: a thin bar dataset as the stem (barThickness
1.5, black, same as the ECharts stem) plus a point-only line dataset
as the dot, on the shared category scale. Supports horizontal
transposition (indexAxis y), color grouping with one dot dataset per
group, and the dotSize property on the same 6-16px visual scale as
ECharts. The stem dataset is filtered out of legend and tooltip.

- register in cjsTemplateDefs (Bar group, same position as ECharts)
- tests: 8 cases (registry, stem/dot shape, zero baseline, transpose,
  color groups, legend/tooltip filters, dotSize mapping, 3-backend
  parity)
- docs: regenerate reference-chartjs.md (npm run gen:reference);
  add Lollipop to the SKILL.md Chart.js coverage list (+ synced asset)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant