Skip to content

Commit

Permalink
fig_height_h_barchart2 handles univariates (#444)
Browse files Browse the repository at this point in the history
  • Loading branch information
sda030 authored Dec 27, 2024
2 parents ee67617 + fedf630 commit 76ee1ad
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion R/fig_height_h_barchart.R
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,8 @@ fig_height_h_barchart2 <- # Returns a numeric value
data <- ggobj$data
# gg <- ggobj



if (!(inherits(data, "data.frame") && nrow(data) > 0)) {
cli::cli_warn("{.arg ggobj} must be a ggplot2-object with a nrow>0 data in it. Returning {.arg min}: {.val {min}}.")
return(min)
Expand Down Expand Up @@ -457,7 +459,7 @@ fig_height_h_barchart2 <- # Returns a numeric value
n_x <- if (length(indep_vars) == 1) 1
n_cats_x <- if (length(indep_vars) == 1) dplyr::n_distinct(data[[indep_vars]])
max_chars_cats_x <- if (length(indep_vars) == 1) max(nchar(as.character(data[[indep_vars]])), na.rm = TRUE)
max_chars_labels_x <- nchar(as.character(attr(data[[indep_vars]], "label")))
max_chars_labels_x <- if (length(indep_vars) == 1) nchar(as.character(attr(data[[indep_vars]], "label")))
if (length(max_chars_labels_x) == 0) max_chars_labels_x <- 0


Expand Down

0 comments on commit 76ee1ad

Please sign in to comment.