Skip to content

fix: multi-line facet panel strip labels for facet_grid and facet_wrap (#262)#339

Open
ANAMASGARD wants to merge 3 commits into
masterfrom
f-multiline-facet-panel-titles
Open

fix: multi-line facet panel strip labels for facet_grid and facet_wrap (#262)#339
ANAMASGARD wants to merge 3 commits into
masterfrom
f-multiline-facet-panel-titles

Conversation

@ANAMASGARD

Copy link
Copy Markdown
Contributor

Fixes #262 — animint2 currently joins multi-variable facet strip labels onto one line (cyl: 4; am: 0). This PR makes them render on separate lines like ggplot2 does.
image

Root cause

Facet type Bug location Current join
facet_grid R/z_facets.R build_strip() "; "
facet_wrap R/z_facets.R getStrips.wrap() ", "

draw_strip() in animint.js renders one flat <text> node — no <tspan> support today.

Two-commit structure

Commit 1 (this commit) - failing test only

  • Adds test-renderer1-facet-multiline.R
  • Checks 12 <tspan> elements across 6 panels × 2 variables for both
    facet_grid and facet_wrap
  • Currently fails: length(labels) == 0 (no tspans exist yet)

Commit 2 — implementation

  • R/z_facets.R: change collapse = "; " / ", " -> collapse = "\n"
  • inst/htmljs/animint.js: split on \n, render each line as <tspan>

Join multi-variable facet labels with newlines in R and render each
line as an SVG tspan in draw_strip. Reuse build_strip for facet_wrap
labelling. Update strip layout measurement and legacy wrap test.
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.60976% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.01%. Comparing base (9dce861) to head (82f6f0c).

Files with missing lines Patch % Lines
inst/htmljs/animint.js 72.72% 9 Missing ⚠️
R/z_facets.R 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #339      +/-   ##
==========================================
- Coverage   73.02%   73.01%   -0.02%     
==========================================
  Files         164      164              
  Lines        8837     8870      +33     
==========================================
+ Hits         6453     6476      +23     
- Misses       2384     2394      +10     
Flag Coverage Δ
javascript 81.10% <72.72%> (-0.14%) ⬇️
r 69.15% <87.50%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ANAMASGARD ANAMASGARD requested a review from tdhock June 12, 2026 11:58
@tdhock

tdhock commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

thanks, can you please post a screenshot using the new code?

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.

multi-line facet panel titles

2 participants