Skip to content

feat(chartjs): add Bump Chart template#60

Merged
Chenglong-MS merged 1 commit into
microsoft:devfrom
zl190:feat/chartjs-bump
Jul 20, 2026
Merged

feat(chartjs): add Bump Chart template#60
Chenglong-MS merged 1 commit into
microsoft:devfrom
zl190:feat/chartjs-bump

Conversation

@zl190

@zl190 zl190 commented Jul 18, 2026

Copy link
Copy Markdown

What

The Vega-Lite and ECharts backends ship a Bump Chart template; Chart.js doesn't — assembleChartjs throws on Bump Chart. This PR ports the template, mirroring the ECharts implementation.

Implementation

Line datasets per series over the shared category (time) axis, with y carrying true rank values and reverse: true on the scale — Chart.js supports reversed linear axes natively. That removes the category-index workaround the ECharts template needs. Rank-semantics detection (Rank / Score / Level) and the fallback to a plain value axis for non-rank measures mirror the ECharts template. Registered in the Line & Area group, same position as ECharts. The compiled config is plain JSON (no callback functions).

One cross-backend observation from verification: on the same input, VL puts rank 3 on top while ECharts puts rank 1 on top. The VL template's own comment intends rank 1 on top ("reverse Y so rank 1 is at top"), so this may be a double reversal — Rank semantics already reverse the axis before the template sets reverse again. This PR follows ECharts, which matches the documented Rank behavior; happy to file the VL side separately.

Verification

  • tests/bump-chartjs.test.ts — 6 cases: registry, one dataset per series, reversed rank axis pinned to [1, maxRank], non-rank fallback to a plain value axis, JSON round-trip, 3-backend parity
  • Full suite: 429 + 50 passing, typecheck clean
  • docs/reference-chartjs.md regenerated via npm run gen:reference
  • 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):

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

Note: #59 and this PR both append one line to templates/index.ts and the SKILL.md coverage list; whichever lands second needs a trivial rebase + asset re-sync.

🤖 Generated with Claude Code

Port the Bump template to the Chart.js backend, mirroring the ECharts
implementation (ecBumpChartDef): line-with-points per series over a
shared x axis, with the rank axis reversed so rank 1 sits on top.
Chart.js reverses a linear scale in place (reverse: true), so unlike
the ECharts category-index workaround the series keep their real rank
values and the config stays pure JSON with no tooltip formatter.

Rank detection mirrors the shared rule (Rank/Score/Level semantic on
y and not on x); non-rank inputs fall back to a plain value axis with
the semantic zero decision, like the Line template. Discrete/temporal/
linear x handling and the continuous-extent pinning follow line.ts.

- register in cjsTemplateDefs (Line & Area group, same position as
  ECharts)
- tests: 6 cases (registry, datasets shape, reversed rank axis pinned
  to [1, maxRank], non-rank fallback, JSON round-trip purity,
  3-backend parity)
- docs: regenerate reference-chartjs.md; add Bump to the SKILL.md
  Chart.js coverage list (+ synced bundled asset)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Chenglong-MS
Chenglong-MS merged commit 2a89b5b into microsoft:dev Jul 20, 2026
1 check 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.

2 participants