Use autofit layout for add_forest() flextable#271
Open
Melkiades wants to merge 3 commits into
Open
Conversation
A wide forest table kept a fixed layout and spilled off the page when saved to docx. Setting the flextable layout to autofit lets Word reflow the table to the page width while the plot column keeps its size.
Contributor
Unit Tests Summary 1 files 247 suites 2m 46s ⏱️ Results for commit 43fa83b. ♻️ This comment has been updated with latest results. |
Contributor
Unit Test Performance DifferenceAdditional test case details
Results for commit 36e6f07 ♻️ This comment has been updated with latest results. |
Contributor
Code Coverage SummaryDiff against mainResults for commit: 43fa83b Minimum allowed coverage is ♻️ This comment has been updated with latest results |
Contributor
Author
|
Did UAT. This does not solve the issue as it was already done from the theme. I need to understand better how to have the vertical lines connecting and the nanoplots be represented the same in html (native output from print) and docx export |
`layout = "autofit"` alone emits tblW = 0% (Word "AutoFit to Contents"),
which sizes columns to their natural width; the forest table (fixed 2.5in
plot column plus non-wrapping stat columns, ~11.8in total) still overflows
the page. Pair it with width = 1 to emit tblW = 100% ("AutoFit to Window")
so Word scales the table to the page width while the plot images keep their
2.5in x 0.4in size.
Assert the 100% preferred width in tests, and add autofit/docx/reflow to the
spelling WORDLIST.
The forest-plot column has a fixed width and holds an image rendered to exactly that width. Under the theme's autofit layout Word sizes the column to its content's natural width, and the default 5pt horizontal cell padding pushes the image past the column, expanding the table until it overflows the page in docx. Zero the plot column's horizontal padding so the image fits its cell content box exactly; the plot proportions are unchanged. This supersedes the earlier autofit/100%-width attempts, which did not fix the overflow.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes are proposed in this pull request?
add_forest()now returns a flextable with an autofit layout so wide forest tables reflow to the page width instead of spilling off the page in docx output. (add_forest() flextable overflows the page in docx output #270, @Melkiades)The flextable returned by
add_forest()was wider than the page and kept afixedlayout, so saving to.docxrendered the exact column widths and the table ran off the right edge (the forest plots became unreadable). The images themselves were sized correctly; only the table layout needed to change. Settinglayout = "autofit"lets Word reflow the table while the plot column keeps its 2.5in x 0.4in size.Related to #150 (fixed vs autofit layout discussion).
Reference GitHub issue associated with pull request. closes #270
Pre-review Checklist (if item does not apply, mark is as complete)
usethis::pr_merge_main()devtools::test_coverage()Reviewer Checklist (if item does not apply, mark is as complete)
pkgdown::build_site(). Check the R console for errors, and review the rendered website.devtools::test_coverage()When the branch is ready to be merged:
NEWS.mdwith the changes from this pull request under the heading "# cards (development version)". If there is an issue associated with the pull request, reference it in parentheses at the end update (seeNEWS.mdfor examples).