Skip to content

fix(bar-table): honour Rank ordinal semantics instead of length-encoding it - #103

Merged
Chenglong Wang (Chenglong-MS) merged 2 commits into
microsoft:devfrom
Hughhhhcoder:fix/bar-table-rank-ordinal-encoding
Aug 21, 2026
Merged

fix(bar-table): honour Rank ordinal semantics instead of length-encoding it#103
Chenglong Wang (Chenglong-MS) merged 2 commits into
microsoft:devfrom
Hughhhhcoder:fix/bar-table-rank-ordinal-encoding

Conversation

@Hughhhhcoder

Copy link
Copy Markdown

Summary

Fixes #85.

The Rank semantic type is an ordinal (a standing, not a magnitude). The Bar Table template length-encoded it — bar length plus a sequential colour ramp — which inverted the ranking: rank 1 got the shortest, palest bar and the last-placed item the longest, darkest one.

This PR honours the documented Rank behaviour (Rank → reversed axis (1 on top), discrete color) in both the Vega-Lite and Plotly Bar Table templates:

  • rows are ordered by rank ascending (1 first / on top),
  • colour is a discrete scale (tableau10 for VL / per-rank palette for Plotly) instead of a magnitude ramp,
  • bars are equal-length so the mark no longer implies a magnitude that is not there.

Verification

  • npm run typecheck — clean
  • eslint on changed files — clean
  • vitest run1090/1090 pass, including the new tests/bar-table-rank.test.ts regression test covering both backends.

Notes

The issue also suggests a validate_chart warning for ordinal-on-length-channel as an alternative/generalizing fix. I went with honouring the semantics in the template itself (the direct bug), but I'm happy to add the validator warning on top if maintainers prefer the belt-and-suspenders approach.

…ing it

The Rank semantic type is an ordinal (a standing), not a magnitude. The
Bar Table template length-encoded it — bar length plus a sequential
colour ramp — which inverted the ranking: rank 1 got the shortest,
palest bar and the last-placed item the longest, darkest one.

Honour the documented behaviour ("Rank → reversed axis (1 on top),
discrete color") in both the Vega-Lite and Plotly templates:
- order rows by rank ascending (1 first / on top),
- use a discrete colour scale instead of a magnitude ramp,
- draw equal-length bars so the mark no longer implies a magnitude
  that is not there.

Fixes microsoft#85
@Chenglong-MS
Chenglong Wang (Chenglong-MS) changed the base branch from main to dev August 21, 2026 18:58
@Chenglong-MS

Copy link
Copy Markdown
Contributor

awesome! thanks! I'm merging it to dev, and staged together with the interaction support release planned for the next week.

@Chenglong-MS
Chenglong Wang (Chenglong-MS) merged commit 16234d4 into microsoft:dev Aug 21, 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.

Rank semantic type: Bar Table encodes the ordinal as a bar length, inverting the ranking (Bar Chart handles it correctly)

2 participants