diff --git a/NEWS.md b/NEWS.md index a233c33..c0651d9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,8 @@ * Fixed a bug that would cause reordering of data in some geoms (#314) * The concaveman package is no longer a dependency for `geom_mark_hull()` (#308) +* Setting both label and description to `NA` will now turn off label drawing for + that mark completely while still drawing the mark # ggforce 0.4.1 diff --git a/R/mark_circle.R b/R/mark_circle.R index c6c17c7..efafe9b 100644 --- a/R/mark_circle.R +++ b/R/mark_circle.R @@ -332,6 +332,7 @@ circEncGrob <- function(x = c(0, 0.5, 1, 0.5), y = c(0.5, 1, 0.5, 0), id = NULL, ) if (!is.null(label)) { label <- lapply(seq_len(nrow(label)), function(i) { + if (is.na(label$label[i] %||% NA) && is.na(label$description[i] %||% NA)) return(zeroGrob()) grob <- labelboxGrob(label$label[i], 0, 0, label$description[i], gp = label.gp, pad = label.margin, width = label.width, min.width = label.minwidth, hjust = label.hjust diff --git a/R/mark_ellipse.R b/R/mark_ellipse.R index 4a5e95f..61f02cb 100644 --- a/R/mark_ellipse.R +++ b/R/mark_ellipse.R @@ -261,6 +261,7 @@ ellipEncGrob <- function(x = c(0, 0.5, 1, 0.5), y = c(0.5, 1, 0.5, 0), id = NULL ) if (!is.null(label)) { label <- lapply(seq_len(nrow(label)), function(i) { + if (is.na(label$label[i] %||% NA) && is.na(label$description[i] %||% NA)) return(zeroGrob()) grob <- labelboxGrob(label$label[i], 0, 0, label$description[i], gp = label.gp, pad = label.margin, width = label.width, min.width = label.minwidth, hjust = label.hjust diff --git a/R/mark_hull.R b/R/mark_hull.R index d9516f3..c85f1cc 100644 --- a/R/mark_hull.R +++ b/R/mark_hull.R @@ -246,6 +246,7 @@ hullEncGrob <- function(x = c(0, 0.5, 1, 0.5), y = c(0.5, 1, 0.5, 0), id = NULL, ) if (!is.null(label)) { label <- lapply(seq_len(nrow(label)), function(i) { + if (is.na(label$label[i] %||% NA) && is.na(label$description[i] %||% NA)) return(zeroGrob()) grob <- labelboxGrob(label$label[i], 0, 0, label$description[i], gp = label.gp, pad = label.margin, width = label.width, min.width = label.minwidth, hjust = label.hjust diff --git a/R/mark_rect.R b/R/mark_rect.R index 446de94..5cea216 100644 --- a/R/mark_rect.R +++ b/R/mark_rect.R @@ -243,6 +243,7 @@ rectEncGrob <- function(x = c(0, 0.5, 1, 0.5), y = c(0.5, 1, 0.5, 0), id = NULL, ) if (!is.null(label)) { label <- lapply(seq_len(nrow(label)), function(i) { + if (is.na(label$label[i] %||% NA) && is.na(label$description[i] %||% NA)) return(zeroGrob()) grob <- labelboxGrob(label$label[i], 0, 0, label$description[i], gp = label.gp, pad = label.margin, width = label.width, min.width = label.minwidth, hjust = label.hjust