Skip to content

Commit cb855c1

Browse files
committed
Merge pull request #394 from ropensci/fix/bar-coord-flip
Set proper bar orientation when we detect geom_bar() + coord_flip()
2 parents 599312a + 227ceb0 commit cb855c1

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: plotly
22
Title: Create Interactive Web Graphics via Plotly's JavaScript Graphing Library
3-
Version: 2.2.1
3+
Version: 2.2.2
44
Authors@R: c(person("Carson", "Sievert", role = c("aut", "cre"),
55
email = "cpsievert1@gmail.com"),
66
person("Chris", "Parmer", role = c("aut", "cph"),

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2.2.2 -- 18 Jan 2015
2+
3+
Fix bar orientation when we detect geom_bar() + coord_flip() in ggplotly(). Fixes #390.
4+
15
2.2.1 -- 18 Jan 2015
26

37
Search for axis title in scene object. fixes #393.

R/ggplotly.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,7 @@ gg2list <- function(p) {
940940
y <- tr[["y"]]
941941
tr[["y"]] <- x
942942
tr[["x"]] <- y
943+
if (isTRUE(tr[["type"]] == "bar")) tr$orientation <- "h"
943944
flipped.traces[[trace.i]] <- tr
944945
}
945946
x <- layout[["xaxis"]]

tests/testthat/test-ggplot-bar.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,11 @@ test_that("For a given x value, if multiple y exist, sum them. ", {
184184
y <- y[info$data[[1]]$x]
185185
expect_equal(info$data[[1]]$y, as.numeric(y))
186186
})
187+
188+
p <- ggplot(mtcars, aes(factor(cyl))) + geom_bar() + coord_flip()
189+
190+
test_that("geom_bar() + coord_flip() works", {
191+
info <- expect_traces(g, 1, "coord-flip")
192+
expect_identical(info$data[[1]]$orientation, "h")
193+
})
194+

0 commit comments

Comments
 (0)