Skip to content

Commit ef440d2

Browse files
committed
Merge pull request #335 from ropensci/fix/stack
dont try to merge identical bar traces, fixes #250
2 parents a4a9a1d + 0bd441f commit ef440d2

File tree

5 files changed

+23
-3
lines changed

5 files changed

+23
-3
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.0.10
3+
Version: 2.0.11
44
Authors@R: c(person("Carson", "Sievert", role = c("aut", "cre"),
55
email = "[email protected]"),
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.0.11 -- 11 Dec 2015
2+
3+
Fix #250
4+
15
2.0.10 -- 10 Dec 2015
26

37
Fix #225

R/ggplotly.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ gg2list <- function(p) {
851851
tr.attr <- tr[[must.be.equal]]
852852
criteria[[must.be.equal]] <- isTRUE(all.equal(other.attr, tr.attr))
853853
}
854-
if(all(criteria)){
854+
if(all(criteria) && tr$type != "bar"){
855855
can.merge[[other.i]] <- TRUE
856856
}
857857
}

tests/testthat.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ save_outputs <- function(gg, name) {
5858
res <- RSassign(conn, plotly:::plotlyEnv, "plotlyEnv")
5959
res <- RSeval(conn, "unlockBinding('plotlyEnv', asNamespace('plotly'))")
6060
res <- RSeval(conn, "assign('plotlyEnv', plotlyEnv, pos = asNamespace('plotly'))")
61-
pm <- RSeval(conn, "plotly::plotly_build(gg)")
61+
pm <- RSeval(conn, "tryCatch(plotly::plotly_build(gg), error = function(e) 'plotly build error')")
6262
# it could be that the hash didn't exist, so make sure they're different
6363
if (plot_hash != digest::digest(pm)) {
6464
test_dir <- file.path(this_dir, gsub("\\s+", "-", name))

tests/testthat/test-ggplot-stack.R

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,19 @@ test_that("y value is non-cumulative in stacked bar charts", {
2121
expect_equal(L$data[[2]]$y[2], instructors$number[5])
2222
expect_equal(L$data[[3]]$y[2], instructors$number[6])
2323
})
24+
25+
testd <- data.frame(
26+
group1 = rep(1:3, each = 3),
27+
group2 = LETTERS[1:3],
28+
# We have two 0.2 within each group.
29+
count = c(0.2, 0.2, 0.6)
30+
)
31+
32+
test_that("can stack identical traces", {
33+
p1 <- ggplot(testd, aes(x = factor(group1), y = count,
34+
fill = factor(group2))) +
35+
geom_bar(stat = 'identity', width = 1, position = "stack")
36+
L <- save_outputs(p1, "stack-identical")
37+
expect_equal(length(L$data), 3)
38+
})
39+

0 commit comments

Comments
 (0)