Skip to content

Commit 27465ff

Browse files
committed
fix #6521
1 parent 2429d31 commit 27465ff

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

R/position-stack.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ PositionStack <- ggproto("PositionStack", Position,
154154
flipped_aes <- has_flipped_aes(data)
155155
data <- flip_data(data, flipped_aes)
156156
var <- self$var %||% stack_var(data)
157-
if (!vec_duplicate_any(data$x)) {
157+
if (!vec_duplicate_any(data$x) && !isTRUE(self$fill)) {
158158
# We skip stacking when all data have different x positions so that
159159
# there is nothing to stack
160160
var <- NULL

tests/testthat/test-position-stack.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ test_that("position_stack() can stack correctly when ymax is NA", {
6464
expect_equal(get_layer_data(p)$y, c(1, 2))
6565
})
6666

67+
test_that("position_fill() handles one group per position case", {
68+
df <- data_frame0(x = c("A", "B", "C"), y = 1:3)
69+
p <- ggplot(df, aes(x, y)) + geom_col(position = "fill")
70+
expect_equal(get_layer_data(p)$y, c(1, 1, 1))
71+
})
72+
6773
# Visual tests ------------------------------------------------------------
6874

6975
test_that("Stacking produces the expected output", {

0 commit comments

Comments
 (0)