Skip to content

Commit

Permalink
arrange circles from big to small
Browse files Browse the repository at this point in the history
  • Loading branch information
teunbrand committed Dec 14, 2024
1 parent 6caa1de commit 91c0739
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 93 deletions.
7 changes: 4 additions & 3 deletions R/guide-circles.R
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ GuideCircles <- ggproto(
position <- params$text_position %||% elements$text_position
if (position == "ontop") {
text <- Map(
element_grob, label = key$.label, x = x, y = y,
element_grob, label = key$.label[order(-key$size)], x = x, y = y,
MoreArgs = list(element = elements$text)
)
if (isTRUE(params$clip_text)) {
Expand All @@ -175,7 +175,7 @@ GuideCircles <- ggproto(
y <- switch(position, top = , bottom = NULL, y)

text <- element_grob(
elements$text, x = x, y = y, label = key$.label,
elements$text, x = x, y = y, label = key$.label[order(-key$size)],
margin_x = position %in% c("left", "right"),
margin_y = position %in% c("top", "bottom")
)
Expand Down Expand Up @@ -320,7 +320,8 @@ draw_circle_ticks <- function(element, x, y, padding, position) {
draw_circles <- function(decor, vjust = 0, hjust = 0.5) {

data <- vec_slice(decor$data, decor$data$.draw %||% TRUE)
glyph <- lapply(seq_len(nrow(data)), function(i) {
order <- order(-data$size)
glyph <- lapply(seq_len(nrow(data))[order], function(i) {
decor$draw_key(vec_slice(data, i), decor$params, 0)
})
size <- map_dbl(glyph, function(x) max(x$gp$fontsize %||% 0))
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

0 comments on commit 91c0739

Please sign in to comment.