Skip to content

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

Open
ANAMASGARD wants to merge 4 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 4 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 (e447188) to head (be914e2).

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   69.14%   73.01%   +3.87%     
==========================================
  Files         163      164       +1     
  Lines        6002     8873    +2871     
==========================================
+ Hits         4150     6479    +2329     
- Misses       1852     2394     +542     
Flag Coverage Δ
javascript 81.12% <72.72%> (?)
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?

@ANAMASGARD

ANAMASGARD commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

Sir @tdhock I have posted screenshot using new code, please also review all the PR's I have raised (when you get time ) they all need review once done I can move forward , Thanks .

  • Left: facet_grid(cyl + am ~ .) = row strips show cyl and am on separate lines instead of being joined with ;.
  • Right: facet_wrap(~ cyl + am) = top strips also split onto two lines instead of being joined with ,.
    Both facet paths now match ggplot2's multi-line strip rendering. The test test-renderer1-facet-multiline.R passes locally (12 elements found across 6 panels × 2 variables).
image

@tdhock

tdhock commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

thanks. can you please revise so that the multi-line facet title does not go into the plotting area? (the height / width of the plotting area size needs to be a function of how many lines in the title)

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