Skip to content

Commit

Permalink
sensibly handle blank text
Browse files Browse the repository at this point in the history
  • Loading branch information
teunbrand committed Nov 20, 2023
1 parent 5e29f33 commit 0fcd0f0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions R/guide-axis-theta.R
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ GuideAxisTheta <- ggproto(
}

offset <- max(unit(0, "pt"), elements$major_length, elements$minor_length)
elements$offset <- offset + max(elements$text$margin)
elements$offset <- offset + max(elements$text$margin %||% unit(0, "pt"))
elements
},

Expand All @@ -160,12 +160,16 @@ GuideAxisTheta <- ggproto(

build_labels = function(key, elements, params) {

if (inherits(elements$text, "element_blank")) {
return(zeroGrob())
}

key <- vec_slice(key, !vec_detect_missing(key$.label %||% NA))

# Early exit if drawing no labels
labels <- key$.label
if (length(labels) < 1) {
return(list(zeroGrob()))
return(zeroGrob())
}

# Resolve text angle
Expand Down

0 comments on commit 0fcd0f0

Please sign in to comment.