Skip to content

Commit 24d3c5c

Browse files
committed
Merge pull request #387 from ropensci/fix/point-size-alpha
Fix size and alpha translation for points. Fixes #386
2 parents d199cb8 + 34153b9 commit 24d3c5c

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-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.1.2
3+
Version: 2.1.3
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.1.3 -- 12 Jan 2015
2+
3+
Fix size and alpha translation for geom_point. Fixes #386
4+
15
2.1.2 -- 11 Jan 2015
26

37
Upgraded to plotlyjs 1.4.1. For a list of changes, see https://github.com/plotly/plotly.js/releases/tag/v1.4.1

R/trace_generation.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,10 @@ geom2trace <- list(
590590
)
591591
},
592592
point=function(data, params){
593+
# params contains unique values, but we need _all_ values from the data
594+
for (i in names(params)) {
595+
if (length(params[[i]]) > 1) params[[i]] <- data[[i]]
596+
}
593597
L <- list(
594598
x = data$x,
595599
y = data$y,

tests/testthat/test-ggplot-point.R

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
context("geom_point")
2+
3+
expect_traces <- function(gg, n.traces, name){
4+
stopifnot(is.ggplot(gg))
5+
stopifnot(is.numeric(n.traces))
6+
L <- save_outputs(gg, paste0("smooth-", name))
7+
all.traces <- L$data
8+
no.data <- sapply(all.traces, function(tr) {
9+
is.null(tr[["x"]]) && is.null(tr[["y"]])
10+
})
11+
has.data <- all.traces[!no.data]
12+
expect_equal(length(has.data), n.traces)
13+
list(traces=has.data, layout=L$layout)
14+
}
15+
16+
test_that("geom_point size & alpha translate to a single trace", {
17+
gg <- ggplot(mtcars, aes(cyl, wt)) +
18+
geom_point(aes(size = gear, alpha = cyl))
19+
info <- save_outputs(gg, "point-size-alpha")
20+
expect_equal(length(info$data), 1)
21+
mkr <- info$data[[1]]$marker
22+
expect_equal(length(mkr$size), nrow(mtcars))
23+
expect_equal(length(mkr$opacity), nrow(mtcars))
24+
})

0 commit comments

Comments
 (0)