diff --git a/DESCRIPTION b/DESCRIPTION index fcbb7ac0ce..3cbdcf74a0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: plotly Title: Create Interactive Web Graphics via Plotly's JavaScript Graphing Library -Version: 2.2.1 +Version: 2.2.2 Authors@R: c(person("Carson", "Sievert", role = c("aut", "cre"), email = "cpsievert1@gmail.com"), person("Chris", "Parmer", role = c("aut", "cph"), diff --git a/NEWS b/NEWS index 2d79835e71..1b796b74d2 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +2.2.2 -- 18 Jan 2015 + +Fix bar orientation when we detect geom_bar() + coord_flip() in ggplotly(). Fixes #390. + 2.2.1 -- 18 Jan 2015 Search for axis title in scene object. fixes #393. diff --git a/R/ggplotly.R b/R/ggplotly.R index 45c6a37d18..0e144774ac 100644 --- a/R/ggplotly.R +++ b/R/ggplotly.R @@ -940,6 +940,7 @@ gg2list <- function(p) { y <- tr[["y"]] tr[["y"]] <- x tr[["x"]] <- y + if (isTRUE(tr[["type"]] == "bar")) tr$orientation <- "h" flipped.traces[[trace.i]] <- tr } x <- layout[["xaxis"]] diff --git a/tests/testthat/test-ggplot-bar.R b/tests/testthat/test-ggplot-bar.R index 86b947d286..a9e4866909 100644 --- a/tests/testthat/test-ggplot-bar.R +++ b/tests/testthat/test-ggplot-bar.R @@ -184,3 +184,11 @@ test_that("For a given x value, if multiple y exist, sum them. ", { y <- y[info$data[[1]]$x] expect_equal(info$data[[1]]$y, as.numeric(y)) }) + +p <- ggplot(mtcars, aes(factor(cyl))) + geom_bar() + coord_flip() + +test_that("geom_bar() + coord_flip() works", { + info <- expect_traces(g, 1, "coord-flip") + expect_identical(info$data[[1]]$orientation, "h") +}) +