Skip to content

Commit 2e0030e

Browse files
committed
Duplicated values of positional attributes are no longer removed
1 parent 42c0d7c commit 2e0030e

File tree

4 files changed

+27
-10
lines changed

4 files changed

+27
-10
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.js'
3-
Version: 4.0.0
3+
Version: 4.0.1
44
Authors@R: c(person("Carson", "Sievert", role = c("aut", "cre"),
55
email = "[email protected]"),
66
person("Chris", "Parmer", role = c("aut", "cph"),

NEWS.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
1-
4.0.1 -- 14 June 2016
1+
# 4.0.1 -- 14 June 2016
2+
3+
## BUG FIXES
4+
5+
* Duplicated values of positional attributes are no longer removed (bug was introduced in v4.0.0).
6+
7+
## OTHER CHANGES
28

39
* Upgraded to plotly.js v1.14.2 -- https://github.com/plotly/plotly.js/releases/tag/v1.14.2
410

5-
4.0.0 -- 13 June 2016
11+
# 4.0.0 -- 13 June 2016
612

7-
BREAKING CHANGES & IMPROVEMENTS:
13+
## BREAKING CHANGES & IMPROVEMENTS:
814

9-
* Formulas (instead of plain expressions) are now required when using variable mappings. For example, `plot_ly(mtcars, x = wt, y = mpg, color = vs)` should now be `plot_ly(mtcars, x = ~wt, y = ~mpg, color = ~vs)`. This is a major breaking change, but it is necessary to ensure that evaluation is correct in all contexts (as a result, `evaluate` argument is now deprecated as it is no longer needed). It also has the benefit of being easier to program with (i.e., writing your own custom functions that wrap `plot_ly()`). For more details, see the [lazyeval vignette](https://github.com/hadley/lazyeval/blob/master/vignettes/lazyeval.Rmd)
15+
* Formulas (instead of plain expressions) are now required when using variable mappings. For example, `plot_ly(mtcars, x = wt, y = mpg, color = vs)` should now be `plot_ly(mtcars, x = ~wt, y = ~mpg, color = ~vs)`. This is a major breaking change, but it is necessary to ensure that evaluation is correct in all contexts (as a result, `evaluate` argument is now deprecated as it is no longer needed). It also has the benefit of being easier to program with (i.e., writing your own custom functions that wrap `plot_ly()`) since it preserves [referential transparency](https://en.wikipedia.org/wiki/Referential_transparency). For more details, see the [lazyeval vignette](https://github.com/hadley/lazyeval/blob/master/vignettes/lazyeval.Rmd)
1016
* The data structure used to represent plotly objects is now an htmlwidget object (instead of a data frame with a special attribute tracking visual mappings). As a result, the `as.widget()` function has been deprecated, and [serialization/memory leak problems](https://github.com/rstudio/shiny/issues/1151) are no longer an issue. This change also implies that arbitrary data manipulation functions can no longer be intermingled inside a plot pipeline, but plotly methods for dplyr's data manipulation verbs are now provided (see `?plotly_data` for examples).
1117
* The `group` variable mapping no longer create multiple traces, but instead defines "gaps" within a trace (fixes #418, #381, #577). Groupings should be declared via the new `group_by()` function (see `help(plotly_data)` for examples) instead of the `group` argument (which is now deprecated).
1218
* `plot_ly()` now _initializes_ a plotly object (i.e., won't add a scatter trace by default), meaning that something like `plot_ly(x = 1:10, y = 1:10) %>% add_trace(y = 10:1)` creates one trace, instead of two. That being said, if you manually specify a trace type in `plot_ly()`, it will add a layer with that trace type (e.g. `plot_ly(x = 1:10, y = 1:10, type = "scatter") %>% add_trace(y = 10:1)` draws two scatter traces). If no trace type is provided, a sensible type is inferred from the supplied data, and automatically added (i.e., `plot_ly(x = rnorm(100))` now creates a histogram).
1319
* The `inherit` argument is deprecated. Any arguments/attributes specified in `plot_ly()` will automatically be passed along to additional traces added via `add_trace()` (or any of it's `add_*()` siblings).
1420
* Aesthetic scaling (e.g., `color`, `symbol`, `size`) is applied at the plot-level, instead of the trace level.
21+
* Size is no longer automatically included in hovertext (closes #549).
1522

16-
NEW FEATURES & IMPROVEMENTS:
23+
## NEW FEATURES & IMPROVEMENTS:
1724

1825
* Added `linetype`/`linetypes` arguments for mapping discrete variables to line types (works very much like the `symbol`/`symbols`).
19-
* Scaling for aesthetics can be avoided via `I()` (closes #428). This is mainly useful for changing default appearance (e.g. `plot_ly(x = 1:10, y = 1:10, color = I(rainbow(10)))`).
26+
* Scaling for aesthetics can be avoided via `I()` (closes #428). This is mainly useful for changing default appearance (e.g. `plot_ly(x = 1:10, y = 1:10, color = I("red"))`).
2027
* Symbols and linetypes now recognize `pch` and `lty` values (e.g. `plot_ly(x = 1:25, y = 1:25, symbol = I(0:24))`)
2128
* A new `alpha` argument controls the alpha transparency of `color` (e.g. `plot_ly(x = 1:10, y = 1:10, color = I("red"), alpha = 0.1)`).
2229
* Added a `sizes` argument for controlling the range of marker size scaling.
@@ -28,7 +35,7 @@ NEW FEATURES & IMPROVEMENTS:
2835
* New `plotly_json()` function for inspecting the data sent to plotly.js (as an R list or JSON).
2936
* `layout()` is now a generic function and uses method dispatch to avoid conflicts with `graphics:layout()` (fixes #464).
3037

31-
OTHER CHANGES:
38+
## OTHER CHANGES:
3239

3340
* Upgraded to plotly.js v1.14.1 -- https://github.com/plotly/plotly.js/releases/tag/v1.14.1
3441

R/plotly_build.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ plotly_build.plotly <- function(p) {
9595
# Fortunately, variable mappings don't make much sense with one observation,
9696
# and that is the whole point of "recovering" the built data here, so we just ignore
9797
# cases with one row
98-
isVar <- attrLengths > 1 & attrLengths == nobs & !vapply(trace, is.matrix, logical(1))
98+
isVar <- (attrLengths > 1 & attrLengths == nobs) &
99+
!vapply(trace, is.matrix, logical(1)) &
100+
!vapply(trace, is.bare.list, logical(1))
99101
builtData <- data.frame(trace[isVar], stringsAsFactors = FALSE)
100102

101103
if (NROW(builtData) > 0) {
@@ -181,7 +183,11 @@ plotly_build.plotly <- function(p) {
181183
retrace.first = inherits(x, "plotly_polygon")
182184
)
183185
for (i in x$.plotlyVariableMapping) {
184-
x[[i]] <- structure(uniq(d[[i]]), class = oldClass(x[[i]]))
186+
# try to reduce the amount of data we have to send for non-positional scales
187+
x[[i]] <- structure(
188+
if (i %in% npscales()) uniq(d[[i]]) else d[[i]],
189+
class = oldClass(x[[i]])
190+
)
185191
}
186192
x
187193
})

R/utils.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ is.colorbar <- function(tr) {
1010
inherits(tr, "plotly_colorbar")
1111
}
1212

13+
is.bare.list <- function(x) {
14+
is.list(x) && !is.data.frame(x)
15+
}
16+
1317
"%||%" <- function(x, y) {
1418
if (length(x) > 0 || is_blank(x)) x else y
1519
}

0 commit comments

Comments
 (0)