Skip to content

Commit

Permalink
cross_none can be used in circular layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Yunuuuu committed Jan 2, 2025
1 parent 09de9c3 commit 2a1d271
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
15 changes: 15 additions & 0 deletions R/cross-link.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@ cross_link <- function(link, data = waiver(), on_top = TRUE,
#' @importFrom grid grob
#' @include cross-none.R
CrossLink <- ggproto("CrossLink", CrossNone,
interact_layout = function(self, layout) {
if (!self$in_linear) { # only used for linear coordinate
cli_abort(c(
sprintf(
"Cannot add %s to %s",
object_name(self), layout_name
),
i = sprintf(
"%s can only be used in linear layout",
object_name(self)
)
))
}
ggproto_parent(CrossNone, self)$interact_layout(layout)
},
build_plot = function(self, plot, design, extra_design = NULL,
previous_design = NULL) {
if (is.null(.subset2(previous_design, "nobs"))) {
Expand Down
15 changes: 15 additions & 0 deletions R/cross-mark.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@ cross_mark <- function(mark, data = waiver(),
#' @importFrom ggplot2 ggproto ggproto_parent
#' @include cross-none.R
CrossMark <- ggproto("CrossMark", CrossNone,
interact_layout = function(self, layout) {
if (!self$in_linear) { # only used for linear coordinate
cli_abort(c(
sprintf(
"Cannot add %s to %s",
object_name(self), layout_name
),
i = sprintf(
"%s can only be used in linear layout",
object_name(self)
)
))
}
ggproto_parent(CrossNone, self)$interact_layout(layout)
},
build_plot = function(self, plot, design, extra_design = NULL,
previous_design = NULL) {
if (is.null(.subset2(previous_design, "nobs"))) {
Expand Down
12 changes: 0 additions & 12 deletions R/cross-none.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,6 @@ cross_none <- function(data = waiver(), inherit_panel = NULL,
#' @include cross-.R
CrossNone <- ggproto("CrossNone", Cross,
interact_layout = function(self, layout) {
if (!self$in_linear) { # only used for linear coordinate
cli_abort(c(
sprintf(
"Cannot add %s to %s",
object_name(self), layout_name
),
i = sprintf(
"%s can only be used in linear layout",
object_name(self)
)
))
}
# will define labels0 using CrossGg
layout <- ggproto_parent(Cross, self)$interact_layout(layout)

Expand Down

0 comments on commit 2a1d271

Please sign in to comment.