Skip to content

feat(s2): bar direct label collision hiding, overflow and dataKey - #993

Open
c-lamoureux wants to merge 4 commits into
mainfrom
feat/s2-bar-direct-label-visibility
Open

c-lamoureux wants to merge 4 commits into
mainfrom
feat/s2-bar-direct-label-visibility

Conversation

@c-lamoureux

Copy link
Copy Markdown
Contributor

Summary

Stacked on #989. Bar direct labels no longer overlap each other or the bars.

  • Follows the bars. Labels read the rendered bar geometry, so they sit on the right bar in dodged and stacked layouts.
  • Hidden on collision. Outside labels are placed with Vega's label transform and hidden if they would overlap a bar or another label. Dodged groups use the full chart size for this, not the group's band width.
  • Hidden when they don't fit. Inside labels (start, middle, end) are hidden when the text doesn't fit in the bar.
  • New overflow prop. 'hide' (default) or 'spill', which moves a label that doesn't fit outside the bar tip, where it is still hidden on collision. start defaults to 'spill'.
  • New dataKey prop. Labels only the rows where that field is truthy, e.g. calling out a single bar. These labels follow the same fit and collision rules.
  • Hidden values remain available through tooltips/inspect.

Docs and dev

  • Docs: spectrum2/bar.md gets a "Labeling specific bars" section and the new props.
  • Stories: Overflow and DataKey.
  • Bar dashboard: overflow hide/spill and dataKey cards, and coverage entries for the new props.

Testing

  • Unit tests for label marks, collision layout, fit tests, dataKey filtering and mark insertion.
  • Checked in Storybook (including resize): dodged labels hide on collision, horizontal stacked labels show, spill labels move outside.
  • yarn verify passes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@c-lamoureux
c-lamoureux force-pushed the feat/s2-bar-dashboard branch from cf4d7a7 to 7c27a88 Compare October 12, 2026 16:17
@c-lamoureux
c-lamoureux force-pushed the feat/s2-bar-direct-label-visibility branch from f03bad7 to 342ba97 Compare October 12, 2026 16:17
Base automatically changed from feat/s2-bar-dashboard to main October 16, 2026 18:26
c-lamoureux and others added 3 commits October 16, 2026 13:18
Use Vega's native bar-bound anchors and collision layout across dodged categories. Filter excluded and inside-fit rows before placement, preserve draw-in fades, and cover geometry updates with runtime regressions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Cover label positions, signs, layouts, collision policies, data updates and animation comparisons. Handle empty obstacle sets in native Vega layout and defer invisible draw-in candidates.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Round the native label bitmap size to integers so fractional trellis facets detect bar collisions, and rasterize labels in a padded frame so later label sets see earlier outside labels. During draw-in, lay labels out from the final background geometry and fade the whole layer in afterwards so plot bounds don't shift. Collapse rejected labels so they don't affect autosize.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
2 New Code Smells (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@github-actions

Copy link
Copy Markdown
Contributor

This branch has not been deployed

No deployments
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