Conversation
Add Multi-line Text Support Throughout animint2Fixes #221 SummaryThis PR enables newline characters ( What Now Works✅ Plot titles - Visual VerificationThe screenshot below demonstrates multi-line text working correctly in all contexts:
Example Usagelibrary(animint2)
data <- data.frame(
x = 1:5,
y = 1:5,
group = c("A", "B", "C", "A", "B"),
label = c("Single", "Two\nLines", "Three\nLines\nHere", "Text", "Label")
)
viz <- animint(
plot1 = ggplot(data, aes(x, y, color = group, label = label)) +
geom_point(size = 5) +
geom_text(vjust = -1) +
ggtitle("Multi-line Test\nIssue #221 Demonstration") +
xlab("X Axis\n(Horizontal Position)") +
ylab("Y Axis\n(Vertical Position)") +
scale_color_discrete(name = "Data Group\n(Click to Select)")
)
animint2dir(viz, "output-dir") |
|
No obvious timing issues in HEAD=multiline-text-support-221 Generated via commit 0875c09 Download link for the artifact containing the test results: ↓ atime-results.zip
|
|
Ran tests locally - all 19 multiline text tests pass successfully. The test failures shown are due to missing optional packages (mapproj, sp, XML) and GitHub API permissions, not related to this PR. Sir can you please help me figure out on how to pass the JS_Coverage test suite . |
|
To get this PR to close the corresponding issue, please add Closes #221 on its own line, in the first comment of the PR. |
|
looks like a step in the right direction, thanks! |
|
Also in #261 (comment) it seems like there is an inconsistency between the X and Y axes.
can this be adjusted to be more consistent please? |
tdhock
left a comment
There was a problem hiding this comment.
please add tests then fix
Tests check: - plot title doesn't overlap with plot area - x-axis and y-axis spacing is consistent - multiline spacing matches single-line baseline Tests currently fail, demonstrating the bugs in current code. Addresses feedback on PR #261.
Two fixes: 1. Add 5px margin below title to prevent overlap with plot area 2. Use same base spacing (30px) for both X and Y axis labels Both axes now have consistent spacing, and multiline titles stay above the plot area. Addresses feedback on PR #261.
tdhock
left a comment
There was a problem hiding this comment.
please simplify height/width calculation
|
can you please post an updated screen shot? |
|
can you please test increasing and decreasing font size? |
|
Sir @tdhock Fixed the axis title font size issue. Axis titles now scale correctly with Changes: Tested with different font sizes (10, 30, 50) - all working locally on my system . Please Sir review it and give your feedback !!! |
|
Sir @tdhock Please give your feedback !!! |
tdhock
left a comment
There was a problem hiding this comment.
please revise and explain
|
Sir @tdhock I have fixed all code style issues :=>
All tests passed locally on my system . |
|
to understand why the test cases fail, you should try running them line by line under chromote, after tests_init(), and then look at the output in the remote controlled web browser window https://github.com/animint/animint2/wiki/Testing |
The xtitle text element was missing the transform attribute, which caused renderer tests to fail with 'subscript out of bounds' errors when trying to access xtitle.attrs[["transform"]]. Added transform='translate(0,0)' to match ytitle and plottitle elements, ensuring consistent structure for all title elements. This fixes test failures in: - test-renderer1-facet-space.R (line 42) - test-renderer1-facet-trivial.R (line 32) Addresses maintainer feedback from PR #261.
|
please click Resolve conversation so reviewers can see which things you have already fixed. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #261 +/- ##
==========================================
- Coverage 73.09% 72.68% -0.42%
==========================================
Files 164 165 +1
Lines 8769 8834 +65
==========================================
+ Hits 6410 6421 +11
- Misses 2359 2413 +54
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
please post updated screenshot |
|
this looks better. |
|
please post new screenshot |
Tests check: - plot title doesn't overlap with plot area - x-axis and y-axis spacing is consistent - multiline spacing matches single-line baseline Tests currently fail, demonstrating the bugs in current code. Addresses feedback on PR animint#261.
Two fixes: 1. Add 5px margin below title to prevent overlap with plot area 2. Use same base spacing (30px) for both X and Y axis labels Both axes now have consistent spacing, and multiline titles stay above the plot area. Addresses feedback on PR animint#261.
The xtitle text element was missing the transform attribute, which caused renderer tests to fail with 'subscript out of bounds' errors when trying to access xtitle.attrs[["transform"]]. Added transform='translate(0,0)' to match ytitle and plottitle elements, ensuring consistent structure for all title elements. This fixes test failures in: - test-renderer1-facet-space.R (line 42) - test-renderer1-facet-trivial.R (line 32) Addresses maintainer feedback from PR animint#261.
Tests check: - plot title doesn't overlap with plot area - x-axis and y-axis spacing is consistent - multiline spacing matches single-line baseline Tests currently fail, demonstrating the bugs in current code. Addresses feedback on PR #261.
Two fixes: 1. Add 5px margin below title to prevent overlap with plot area 2. Use same base spacing (30px) for both X and Y axis labels Both axes now have consistent spacing, and multiline titles stay above the plot area. Addresses feedback on PR #261.
The xtitle text element was missing the transform attribute, which caused renderer tests to fail with 'subscript out of bounds' errors when trying to access xtitle.attrs[["transform"]]. Added transform='translate(0,0)' to match ytitle and plottitle elements, ensuring consistent structure for all title elements. This fixes test failures in: - test-renderer1-facet-space.R (line 42) - test-renderer1-facet-trivial.R (line 32) Addresses maintainer feedback from PR #261.
080c5b6 to
a51683d
Compare
a51683d to
ccd5367
Compare
|
Sir @tdhock the spacing is now consistent. Please review and give feedback . |






Add Multi-line Text Support Throughout animint2
Fixes #221
This PR enables newline characters (\n) to work in all text elements of animint2 visualizations. Users can now create multi-line text in plot titles, axis labels, legend titles, and geom_text labels.
What Now Works:
✅ Plot titles - ggtitle("Line 1\nLine 2")
✅ X-axis titles - xlab("X Axis\nSubtitle")
✅ Y-axis titles - ylab("Y Axis\nSubtitle")
✅ Legend titles - scale_color_discrete(name="Legend\nTitle")
✅ Text labels - geom_text(aes(label="Text\nLabel"))
✅ Tooltips - Already worked, still works (backward compatible)
Below is the screenshots of the scripts i ran locally to verify the test locally they fail as aspected

