Skip to content

Commit

Permalink
🐛 Render legend.background when compose_crux(complete = TRUE) (#54)
Browse files Browse the repository at this point in the history
* crux composition has background

* update snapshots

* add news bullet
  • Loading branch information
teunbrand authored Feb 15, 2025
1 parent 04a1bc7 commit f928d30
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

* Fixed bug hindering `position = "inside"` placement (#42)
* Fixed bug in `theme_guide(key.size, key.height, key.width)` (#41)
* Complete guides based on a crux composition now render the `legend.background`
element (#50)

# legendry 0.2.0

Expand Down
9 changes: 8 additions & 1 deletion R/compose-crux.R
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ ComposeCrux <- ggproto(
title_position = "legend.title.position",
text_position = "legend.text.position",
title = "legend.title",
margin = "legend.margin"
margin = "legend.margin",
background = "legend.background"
),

setup_elements = function(params, elements, theme) {
Expand Down Expand Up @@ -220,6 +221,12 @@ ComposeCrux <- ggproto(
if (!is.null(elems$margin)) {
gt <- gtable_add_padding(gt, elems$margin)
}
if (!is.zero(elems$background)) {
gt <- gtable_add_grob(
gt, element_grob(elems$background), name = "background",
clip = "off", t = 1, r = -1, b = -1, l = 1, z = -Inf
)
}
}
gt
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions tests/testthat/_snaps/guide-colbar/bottom-position.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions tests/testthat/_snaps/guide-colbar/left-position.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions tests/testthat/_snaps/guide-colbar/right-position.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f928d30

Please sign in to comment.