Skip to content

Commit 7ea4d46

Browse files
author
Yunuuuu
committed
refactor: move data field to PatchAlignpatches
1 parent d81ea71 commit 7ea4d46

3 files changed

Lines changed: 7 additions & 9 deletions

File tree

R/alignpatch-.R

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,6 @@ Patch <- ggproto(
206206
#' A [`patch_options`] object used to align the plot.
207207
options = NULL,
208208

209-
#' @field data
210-
#'
211-
#' A list containing metadata used to align the plot.
212-
data = NULL,
213-
214209
#' @field set_options
215210
#'
216211
#' **Description**

R/alignpatch-alignpatches.R

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ TAGS_Z <- 5L
162162
#' @noRd
163163
PatchAlignpatches <- ggproto(
164164
"PatchAlignpatches", Patch,
165+
166+
# @field data
167+
#
168+
# A list containing metadata used to align the plot.
169+
data = NULL,
165170
setup = function(self, options = NULL) {
166171
patches <- lapply(prop(self$plot, "plots"), function(p) {
167172
out <- patch(p)
@@ -358,11 +363,10 @@ PatchAlignpatches <- ggproto(
358363
#' @importFrom S7 prop prop<-
359364
#' @importFrom rlang arg_match0 is_empty
360365
gtable = function(self) {
361-
if (is.null(theme <- self$get_option("theme"))) {
366+
if (is.null(metadata <- self$data)) {
362367
cli_abort("Run `$setup()` to initialize the patches first.")
363368
}
364369

365-
metadata <- self$data
366370
# if no plots, we do nothing --------------------------
367371
if (is_empty(.subset2(metadata, "patches"))) {
368372
return(make_patch_table())
@@ -414,6 +418,7 @@ PatchAlignpatches <- ggproto(
414418
b = TABLE_ROWS * metadata$dims[1L] - BOTTOM_BORDER,
415419
r = TABLE_COLS * metadata$dims[2L] - RIGHT_BORDER
416420
)
421+
theme <- self$get_option("theme")
417422
gt <- self$attach_guide_list(
418423
gt = gt,
419424
guide_list = metadata$guides_list,

man/patch.Rd

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)