diff --git a/NEWS.md b/NEWS.md index 6ad24f5daa..456c2c3054 100644 --- a/NEWS.md +++ b/NEWS.md @@ -8,6 +8,7 @@ * Closed #2218: `highlight(selectize = TRUE)` no longer yields an incorrect selectize.js result when there is a combination of crosstalk and non-crosstalk traces. (#2217) * Closed #2208: `ggplotly()` no longer errors given a `geom_area()` with 1 or less data points (error introduced by new behavior in ggplot2 v3.4.0). (#2209) +* Closed #2220: `ggplotly()` no longer errors on `stat_summary(geom = "crossbar")`. (#2222) # 4.10.1 diff --git a/R/layers2traces.R b/R/layers2traces.R index ac101519fc..01fa7063a2 100644 --- a/R/layers2traces.R +++ b/R/layers2traces.R @@ -562,7 +562,7 @@ to_basic.GeomCrossbar <- function(data, prestats_data, layout, params, p, ...) { # from GeomCrossbar$draw_panel() middle <- base::transform(data, x = xmin, xend = xmax, yend = y, alpha = NA) nm <- linewidth_or_size(GeomCrossbar) - data[[nm]] <- data[[nm]] * params$fatten + data[[nm]] <- data[[nm]] * (params$fatten %||% formals(geom_crossbar)$fatten) list( prefix_class(to_basic.GeomRect(data), "GeomCrossbar"), prefix_class(to_basic.GeomSegment(middle), "GeomCrossbar") diff --git a/inst/examples/shiny/event_data/tests/shinytest/mytest.R b/inst/examples/shiny/event_data/tests/shinytest/mytest.R index 803adf7b71..68c6a9b270 100644 --- a/inst/examples/shiny/event_data/tests/shinytest/mytest.R +++ b/inst/examples/shiny/event_data/tests/shinytest/mytest.R @@ -6,6 +6,7 @@ app$snapshot() app$setInputs(`plotly_hover-A` = "[{\"curveNumber\":0,\"pointNumber\":7,\"x\":24.4,\"y\":3.19,\"customdata\":\"Merc 240D\"}]", allowInputNoBinding_ = TRUE) app$setInputs(`plotly_click-A` = "[{\"curveNumber\":0,\"pointNumber\":7,\"x\":24.4,\"y\":3.19,\"customdata\":\"Merc 240D\"}]", allowInputNoBinding_ = TRUE) app$setInputs(`plotly_hover-A` = character(0), allowInputNoBinding_ = TRUE) +Sys.sleep(1) app$snapshot() app$setInputs(`plotly_brushing-A` = "{\"x\":[25.726819184123485,25.98332414553473],\"y\":[1.3174499999999998,5.61955]}", allowInputNoBinding_ = TRUE) app$setInputs(`plotly_selecting-A` = "[]", allowInputNoBinding_ = TRUE) diff --git a/tests/testthat/_snaps/ggplot-summary/stat-summary.svg b/tests/testthat/_snaps/ggplot-summary/stat-summary.svg new file mode 100644 index 0000000000..f0f682369d --- /dev/null +++ b/tests/testthat/_snaps/ggplot-summary/stat-summary.svg @@ -0,0 +1 @@ +setosaversicolorvirginica5678SpeciesSepal.Length diff --git a/tests/testthat/test-ggplot-summary.R b/tests/testthat/test-ggplot-summary.R new file mode 100644 index 0000000000..39f243f642 --- /dev/null +++ b/tests/testthat/test-ggplot-summary.R @@ -0,0 +1,7 @@ +test_that("stat_summary works", { + p <- ggplot(iris, aes(x = Species, y = Sepal.Length)) + + stat_summary(fun = mean, fun.max = max, fun.min = min) + + stat_summary(fun = median, geom = "crossbar", linetype = "dashed") + + expect_doppelganger_built(p, "stat-summary") +})