Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
77dd60b
add tests for multiline text support
ANAMASGARD Oct 21, 2025
ed333c9
implement multiline text support in titles and labels
ANAMASGARD Oct 21, 2025
34a76b0
Merge branch 'master' into multiline-text-support-221
ANAMASGARD Oct 22, 2025
f7ccfc6
add tests for multiline text spacing bugs
ANAMASGARD Oct 22, 2025
fdb0ddc
fix multiline text spacing bugs
ANAMASGARD Oct 22, 2025
9d4e1ba
simplify text measurement and remove magic numbers
ANAMASGARD Oct 22, 2025
1e06e57
Merge branch 'master' into multiline-text-support-221
ANAMASGARD Oct 22, 2025
6452fef
Resolve NEWS.md merge conflict - keep both PR#266 and PR#221 entries
ANAMASGARD Oct 23, 2025
306df14
Merge branch 'multiline-text-support-221' of https://github.com/animi…
ANAMASGARD Oct 23, 2025
f3e758c
Merge branch 'master' into multiline-text-support-221
ANAMASGARD Oct 23, 2025
fbfb3aa
Simplify multiline text rendering - remove redundant if-else pattern
ANAMASGARD Oct 23, 2025
50530fb
Merge branch 'multiline-text-support-221' of https://github.com/animi…
ANAMASGARD Oct 23, 2025
400e49c
Remove unnecessary blank lines from test-multiline-spacing.R
ANAMASGARD Oct 23, 2025
4ac0712
Remove extra blank lines from tests
ANAMASGARD Oct 23, 2025
59526cd
Merge branch 'master' into multiline-text-support-221
ANAMASGARD Nov 7, 2025
1ead178
fix: axis titles now scale with theme text size
ANAMASGARD Nov 7, 2025
6099a84
test: add coverage for axis title font-size inheritance
ANAMASGARD Nov 7, 2025
ee37e3a
docs: add NEWS entry for PR#261 fixes
ANAMASGARD Nov 7, 2025
f766f9c
style: fix indentation and document lineHeight
ANAMASGARD Nov 7, 2025
a3c633c
Merge branch 'master' into multiline-text-support-221
ANAMASGARD Nov 7, 2025
d08d9c4
fix: add missing transform attribute to xtitle element
ANAMASGARD Nov 8, 2025
3d7f2d8
fix: use correct transform pattern for title elements
ANAMASGARD Nov 8, 2025
300537c
Replace jsonlite with RJSONIO and add multiline spacing test
ANAMASGARD Nov 11, 2025
2b1a3cf
Merge branch 'master' into multiline-text-support-221
ANAMASGARD Nov 21, 2025
0f960ca
fix: use correct get_element_bbox signature in multiline tests
ANAMASGARD Nov 27, 2025
acbc6da
fix label=0 rendering and title positioning
ANAMASGARD Nov 27, 2025
dee2e85
Merge branch 'master' into multiline-text-support-221
ANAMASGARD Dec 3, 2025
0531859
fix: make X and Y axis title spacing consistent
ANAMASGARD Dec 3, 2025
35eed55
Merge branch 'master' into multiline-text-support-221
ANAMASGARD Dec 5, 2025
22f0cb8
fix: restore original axis padding values to fix rotation tests
ANAMASGARD Dec 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ Collate:
'uu_zzz.r'
'z_animint.R'
'z_animintHelpers.R'
'z_multiline.R'
'z_facets.R'
'z_geoms.R'
'z_helperFunctions.R'
Expand Down
15 changes: 12 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@

- `update_axes`: Fixed issue #273 where axis tick text font-size was inconsistent between plots with and without `update_axes`. Previously, plots using `theme_animint(update_axes="x")` would lose `theme(axis.text = element_text(size=...))` styling after axis updates.

# Changes in version 2025.11.7 (PR#261)

- Fixed multiline text spacing: plot titles no longer overlap with plot area, and X/Y axis label spacing is now consistent.
- Fixed axis titles to scale correctly with `theme(text=element_text(size=X))` (issue #64).

# Changes in version 2025.10.31 (PR#271)

- `geom_point()` now warns when shape parameter is set to a value other than 21, since animint2 web rendering only supports shape=21 for proper display of both color and fill aesthetics.
Expand All @@ -26,6 +31,10 @@

- `geom_text(vjust!=0)` warning mentions vjust support in `geom_label_aligned()`.

# Changes in version 2025.10.21 (PR#221)

- Multi-line text support: `\n` now works in plot titles, axis titles, legend titles, and `geom_text()` labels. Created `R/z_multiline.R` with helper to convert `\n` to `<br/>` during R compilation. JavaScript renderer converts `<br/>` to SVG `<tspan>` elements for proper multi-line display.

# Changes in version 2025.10.17 (PR#255)

- `getCommonChunk()` uses default group=1 (previously 1:N which was slower).
Expand Down Expand Up @@ -129,7 +138,7 @@

# Changes in version 2025.1.24 (PR#164)

- New Start Tour widget at the bottom of each data viz, which highlights what interactions are possible with each geom. Use `geom_*(title="title for geom in tour", help="details about what this geom is supposed to represent)` to change what is displayed for each geom during the tour. Powered by https://driverjs.com/
- New Start Tour widget at the bottom of each data viz, which highlights what interactions are possible with each geom. Use `geom_*(title="title for geom in tour", help="details about what this geom is supposed to represent)` to change what is displayed for each geom during the tour. Powered by [https://driverjs.com/](https://driverjs.com/)

# Changes in version 2025.1.21 (PR#181)

Expand Down Expand Up @@ -209,7 +218,7 @@
be the URL of data viz source code, used to display a link below the
rendered viz.
- New function `update_gallery("path/to/gallery_repo")` for updating
galleries such as https://animint.github.io/gallery/
galleries such as [https://animint.github.io/gallery/](https://animint.github.io/gallery/)
- Bugfix: geom_text renders color as svg fill style (was rendering as
stroke style, a regression introduced by the initial implementation
of `fill_off`).
Expand Down Expand Up @@ -251,7 +260,7 @@

# Changes in 2022.5.25

- Add ability to rotate geom_text labels, following ggplot2's semantics of rotation direction.
- Add ability to rotate geom_text labels, following ggplot2\'s semantics of rotation direction.

# Changes in 2022.5.24

Expand Down
15 changes: 11 additions & 4 deletions R/z_animint.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ parsePlot <- function(meta, plot, plot.name){
for (xy in c("x", "y")) {
s <- function(tmp) sprintf(tmp, xy)
# one axis name per plot (ie, a xtitle/ytitle is shared across panels)
plot.info[[s("%stitle")]] <- if(is.blank(s("axis.title.%s"))){
axis_title_raw <- if(is.blank(s("axis.title.%s"))){
""
} else {
scale.i <- which(plot$scales$find(xy))
Expand All @@ -143,6 +143,10 @@ parsePlot <- function(meta, plot, plot.name){
lab.or.null
}
}
# Convert newlines to <br/> for multi-line axis titles (Issue #221)
plot.info[[s("%stitle")]] <- convertNewlinesToBreaks(axis_title_raw)
## axis title size.
plot.info[[s("%stitle_size")]] <- getTextSize(s("axis.title.%s"), theme.pars)
## panel text size.
plot.info[[s("strip_text_%ssize")]] <- getTextSize(
s("strip.text.%s"), theme.pars)
Expand Down Expand Up @@ -187,12 +191,13 @@ parsePlot <- function(meta, plot, plot.name){
# grab the unique axis labels (makes rendering simpler)
plot.info <- getUniqueAxisLabels(plot.info)

# grab plot title if present
plot.info$title <- if(is(theme.pars$plot.title, "blank")){
# grab plot title if present and convert newlines (Issue #221)
plot_title_raw <- if(is(theme.pars$plot.title, "blank")){
""
}else{
plot$labels$title
}
plot.info$title <- convertNewlinesToBreaks(plot_title_raw)
plot.info$title_size <- getTextSize("plot.title", theme.pars)

## Set plot width and height from animint.* options if they are
Expand Down Expand Up @@ -744,7 +749,6 @@ getLegendList <- function(plistextra){
gdefs <- guides_merge(gdefs)
gdefs <- guides_geom(gdefs, layers, default_mapping)
} else (zeroGrob())
names(gdefs) <- sapply(gdefs, function(i) i$title)

## adding the variable used to each LegendList
for(leg in seq_along(gdefs)) {
Expand Down Expand Up @@ -824,6 +828,9 @@ getLegendList <- function(plistextra){
}
}
legend.list <- lapply(gdefs, getLegend)
# Use the 'class' field from getLegend output for legend key names (Issue #221)
# This ensures JSON keys don't contain newlines or other special characters
names(legend.list) <- sapply(legend.list, function(i) i$class)
## Add a flag to specify whether or not there is both a color and a
## fill legend to display. If so, we need to draw the interior of
## the points in the color legend as the same color.
Expand Down
16 changes: 14 additions & 2 deletions R/z_animintHelpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,8 @@ getLegend <- function(mb){
names(data) <- paste0(geom, names(data))# aesthetics by geom
names(data) <- gsub(paste0(geom, "."), "", names(data), fixed=TRUE) # label isn't geom-specific
data$label <- paste(data$label) # otherwise it is AsIs.
# Convert newlines to <br/> for multi-line legend labels (Issue #221)
data$label <- convertNewlinesToBreaks(data$label)
data
}
dataframes <- mapply(function(i, j) cleanData(i$data, mb$key, j, i$params),
Expand All @@ -710,10 +712,16 @@ getLegend <- function(mb){
if(guidetype=="none"){
NULL
}else{
# Convert newlines to <br/> for multi-line legend title (Issue #221)
legend_title <- convertNewlinesToBreaks(mb$title)
# For the 'class' field (used as JSON key), sanitize newlines to spaces
# to avoid JSON parsing issues with control characters (Issue #221)
safe_title <- gsub("\n", " ", mb$title, fixed = TRUE)
legend_class <- if(mb$is.discrete) mb$selector else safe_title
list(guide = guidetype,
geoms = unlist(mb$geom.legend.list),
title = mb$title,
class = if(mb$is.discrete)mb$selector else mb$title,
title = legend_title,
class = legend_class,
selector = mb$selector,
is_discrete= mb$is.discrete,
legend_type = mb$legend_type,
Expand Down Expand Up @@ -897,6 +905,10 @@ split_recursive <- function(x, vars){
##' @author Toby Dylan Hocking
saveChunks <- function(x, meta){
if(is.data.frame(x)){
# Convert newlines to <br/> in label column for multi-line text (Issue #221)
if("label" %in% names(x)){
x$label <- convertNewlinesToBreaks(x$label)
}
this.i <- meta$chunk.i
csv.name <- sprintf("%s_chunk%d.tsv", meta$g$classed, this.i)
## Some geoms should be split into separate groups if there are NAs.
Expand Down
4 changes: 4 additions & 0 deletions R/z_multiline.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
convertNewlinesToBreaks <- function(text) {
gsub("\n", "<br/>", text, fixed = TRUE)
}

Loading