Skip to content

Commit c47df47

Browse files
committed
Merge pull request #129 from ropensci/marianne-fix-bar-null
Fix bar chart conversion for position="dodge" (barmode="group" in Plotly)
2 parents 51a2b91 + 42e0cb5 commit c47df47

File tree

132 files changed

+34
-7
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+34
-7
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: plotly
22
Type: Package
33
Title: Interactive, publication-quality graphs online.
4-
Version: 0.5.2
4+
Version: 0.5.3
55
Authors@R: c(person("Chris", "Parmer", role = c("aut", "cre"),
66
email = "[email protected]"),
77
person("Scott", "Chamberlain", role = "aut",

NEWS

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
0.5.3 -- 21 October 2014.
2+
3+
Support conversion of geom_bar() with position_dodge().
4+
5+
0.5.2 -- 18 October 2014.
6+
7+
Support aesthetic shape in geom_path() and, hence, geom_line() (conversion).
8+
9+
0.5.1 -- 15 October 2014.
10+
11+
Do not show zero lines by default (as in ggplot2 plots).
12+
13+
0.5.0 -- 15 October 2014.
14+
15+
From now on, version numbers are meaningful again...
16+
Many changes meanwhile, especially support for more geoms.
17+
118
0.4 -- 7 April 2014.
219

320
Re-write geom to trace conversion code.
@@ -22,4 +39,4 @@ For ggplotly:
2239

2340
Merge ggplotly code.
2441

25-
0.3.5
42+
0.3.5

R/trace_generation.R

+5-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ layer2traces <- function(l, d, misc) {
178178
}
179179
}
180180
name.names <- grep("[.]name$", names(data.params$params), value=TRUE)
181-
if(length(name.names)){
181+
if (length(name.names)) {
182182
for(a.name in name.names){
183183
a <- sub("[.]name$", "", a.name)
184184
a.value <- as.character(data.params$params[[a.name]])
@@ -189,6 +189,8 @@ layer2traces <- function(l, d, misc) {
189189
}
190190
name.list <- data.params$params[name.names]
191191
tr$name <- paste(unlist(name.list), collapse=".")
192+
if (length(unique(name.list)) < 2)
193+
tr$name <- as.character(name.list[[1]])
192194
}
193195

194196
dpd <- data.params$data
@@ -268,6 +270,8 @@ toBasic <- list(
268270
g
269271
},
270272
bar=function(g) {
273+
if (any(is.na(g$prestats.data$x)))
274+
g$prestats.data$x <- g$prestats.data$x.name
271275
g$prestats.data$fill <- g$data$fill[match(g$prestats.data$group, g$data$group)]
272276
g$params$xstart <- min(g$data$xmin)
273277
g$params$xend <- max(g$data$xmax)

run_tests_with_outputs.R

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ save_outputs <- function(gg, name, ignore_ggplot=FALSE) {
1414
if (!ignore_ggplot) {
1515
ggsave(paste0("test-ggplot-", name, "-ggplot2.png"), plot=gg, w=7, h=5)
1616
}
17-
18-
# save the json
19-
writeLines(getURL(paste0(plotlyUrl, ".json")), paste0("test-ggplot-", name, ".json"))
17+
18+
# Save the json
19+
writeLines(getURL(paste0(plotlyUrl, ".json")), paste0("test-ggplot-", name,
20+
".json"))
2021
}
2122

2223
test_check("plotly")

tests/testthat.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
library(testthat)
22
save_outputs <- function(gg, name, ignore_ggplot=FALSE) {
3-
print(paste("running", name))
3+
print(paste("running", name))
44
}
55
test_check("plotly")
-107 KB
Binary file not shown.
-21.5 KB
Binary file not shown.
-86.2 KB
Binary file not shown.
-21.7 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
-87.7 KB
Binary file not shown.
-21.3 KB
Binary file not shown.
-93.7 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-93.6 KB
Binary file not shown.
-21.8 KB
Binary file not shown.

tests/testthat/test-ggplot-bar.R

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ test_that("position_dodge is translated to barmode=group", {
1515
trace.names <- sapply(L[1:2], "[[", "name")
1616
expect_true(all(c("Math", "Bio") %in% trace.names))
1717
expect_identical(L$kwargs$layout$barmode, "group")
18+
# Check x values
19+
expect_identical(as.character(L[[1]]$x[1]), "Canada")
20+
expect_identical(as.character(L[[1]]$x[2]), "Germany")
21+
expect_identical(as.character(L[[2]]$x[1]), "Canada")
22+
expect_identical(as.character(L[[2]]$x[2]), "USA")
1823

1924
save_outputs(gg.dodge, "bar-dodge")
2025
})
Binary file not shown.
Binary file not shown.
-88.9 KB
Binary file not shown.
-21.7 KB
Binary file not shown.
-446 KB
Binary file not shown.
-85.8 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-132 KB
Binary file not shown.
-21.6 KB
Binary file not shown.
-397 KB
Binary file not shown.
-66.4 KB
Binary file not shown.
-117 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
-26 KB
Binary file not shown.
-101 KB
Binary file not shown.
-25.9 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-78.4 KB
Binary file not shown.
-20.9 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-31.9 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-499 KB
Binary file not shown.
-68.1 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-20.4 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-180 KB
Binary file not shown.
-49.7 KB
Binary file not shown.
-82.9 KB
Binary file not shown.
-17.4 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-97.8 KB
Binary file not shown.
-20.8 KB
Binary file not shown.
-98.9 KB
Binary file not shown.
-22.1 KB
Binary file not shown.
-22.1 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-347 KB
Binary file not shown.
-53.5 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-128 KB
Binary file not shown.
-21.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)