Skip to content

Commit ddb8b30

Browse files
committed
merge with master
2 parents 3c85052 + 3bdb921 commit ddb8b30

File tree

331 files changed

+543
-360
lines changed

Some content is hidden

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

331 files changed

+543
-360
lines changed

.travis.yml

+14-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
language: R
22
cache: packages
3-
sudo: true
4-
dist: trusty
53
warnings_are_errors: false
4+
65
r:
76
- devel
87
- oldrel
98
- release
9+
10+
addons:
11+
apt:
12+
sources:
13+
- sourceline: 'ppa:ubuntugis/ppa'
14+
packages:
15+
- libudunits2-dev
16+
- libproj-dev
17+
- libgeos-dev
18+
- libgdal-dev
1019

1120
env:
1221
global:
@@ -21,12 +30,6 @@ env:
2130

2231
before_install:
2332
- echo "Sys.setenv('plotly_username' = 'cpsievert')" > ~/.Rprofile
24-
# sf system dependencies
25-
- sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable --yes
26-
- sudo apt-get --yes --force-yes update -qq
27-
- sudo apt-get install --yes libudunits2-dev libproj-dev libgeos-dev libgdal-dev
28-
# make sure R pkgs are upt-to-date
29-
- Rscript -e 'update.packages(ask = FALSE)'
3033

3134
before_script:
3235
- if [[ "$TRAVIS_R_VERSION_STRING" == "release" ]]; then docker run -e GITHUB_PAT=$GITHUB_PAT -e MAPBOX_TOKEN=$MAPBOX_TOKEN -e VMODE="ci" -v $(pwd):/home/plotly --privileged cpsievert/plotly-orca; fi
@@ -35,4 +38,6 @@ before_script:
3538
r_packages: devtools
3639

3740
# temporary: needed for plotly input testing in shiny
38-
r_github_packages: rstudio/shinytest
41+
r_github_packages:
42+
- rstudio/shinytest
43+
- r-lib/remotes

DESCRIPTION

+1-1
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.8.0.9000
3+
Version: 4.9.0.9000
44
Authors@R: c(person("Carson", "Sievert", role = c("aut", "cre"),
55
email = "[email protected]", comment = c(ORCID = "0000-0002-4958-2844")),
66
person("Chris", "Parmer", role = "aut",

NEWS.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
# 4.8.0.9000
1+
# 4.9.0.9000
2+
3+
## Changes to plotly.js
4+
5+
* This version of the R package upgrades the version of the underlying plotly.js library from v1.46.1 to v1.48.3. The [plotly.js release page](https://github.com/plotly/plotly.js/releases) has the full list of changes.
6+
7+
8+
# 4.9.0
29

310
## Changes to plotly.js
411

@@ -41,6 +48,7 @@
4148
- When `xref`/`yref` references an x/y axis these references are bumped accordingly (#1181).
4249
- When `xref`/`yref` references paper coordinates, these coordinates are updated accordingly (#1332).
4350
* `subplot()` now repositions shapes with fixed height/width (i.e., `xsizemode`/`ysizemode` of `"pixel"`) correctly (#1494).
51+
* The `colorscale` attribute now correctly handles a wider range of input values (#1432, #1485)
4452
* The colorscale generated via the `color` argument in `plot_ly()` now uses an evenly spaced grid of values instead of quantiles (#1308).
4553
* When using **shinytest** to test a **shiny** that contains **plotly** graph, false positive differences are no longer reported (rstudio/shinytest#174).
4654
* When the `size` argument maps to `marker.size`, it now converts to an array of appropriate length (#1479).

R/partial_bundles.R

+1-2
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,7 @@ bundleTraceMap <- list(
189189
"scatter3d",
190190
"surface",
191191
"mesh3d",
192-
"cone",
193-
"isosurface"
192+
"cone"
194193
),
195194
gl2d = c(
196195
"scatter",

R/plotly.R

+3-1
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,13 @@ plot_geo <- function(data = data.frame(), ..., offline = FALSE) {
310310
#' @seealso [plot_ly()], [plot_mapbox()], [ggplotly()]
311311
#' @examples
312312
#'
313+
#' \dontrun{
313314
#' hc <- hclust(dist(USArrests), "ave")
314315
#' dend1 <- as.dendrogram(hc)
315316
#' plot_dendro(dend1, height = 600) %>%
316317
#' hide_legend() %>%
317318
#' highlight(persistent = TRUE, dynamic = TRUE)
319+
#' }
318320
#'
319321

320322
plot_dendro <- function(d, set = "A", xmin = -50, height = 500, width = 500, ...) {
@@ -444,7 +446,7 @@ typedArrayPolyfill <- function() {
444446
plotlyMainBundle <- function() {
445447
htmltools::htmlDependency(
446448
name = "plotly-main",
447-
version = "1.46.1",
449+
version = "1.48.3",
448450
package = "plotly",
449451
src = dependency_dir("plotlyjs"),
450452
script = "plotly-latest.min.js",

R/subplots.R

+14-9
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ subplot <- function(..., nrows = 1, widths = NULL, heights = NULL, margin = 0.02
266266
}
267267

268268
p <- list(
269-
data = Reduce(c, traces),
269+
data = unlist(traces, recursive = FALSE),
270270
layout = Reduce(modify_list, c(xAxes, rev(yAxes)))
271271
)
272272

@@ -275,9 +275,10 @@ subplot <- function(..., nrows = 1, widths = NULL, heights = NULL, margin = 0.02
275275
annotations <- Map(reposition, annotations, split(domainInfo, seq_along(plots)))
276276
shapes <- Map(reposition, shapes, split(domainInfo, seq_along(plots)))
277277
images <- Map(reposition, images, split(domainInfo, seq_along(plots)))
278-
p$layout$annotations <- Reduce(c, annotations)
279-
p$layout$shapes <- Reduce(c, shapes)
280-
p$layout$images <- Reduce(c, images)
278+
p$layout$annotations <- unlist(annotations, recursive = FALSE)
279+
p$layout$shapes <- unlist(shapes, recursive = FALSE)
280+
p$layout$images <- unlist(images, recursive = FALSE)
281+
281282
# merge non-axis layout stuff
282283
layouts <- lapply(layouts, function(x) {
283284
x[!grepl("^[x-y]axis|^geo|^mapbox|annotations|shapes|images", names(x))] %||% list()
@@ -290,8 +291,8 @@ subplot <- function(..., nrows = 1, widths = NULL, heights = NULL, margin = 0.02
290291
}
291292
layouts <- layouts[which_layout]
292293
}
293-
p$attrs <- Reduce(c, lapply(plots, "[[", "attrs"))
294-
p$layout <- modify_list(p$layout, Reduce(modify_list, layouts))
294+
p$attrs <- unlist(lapply(plots, "[[", "attrs"), recursive = FALSE)
295+
p$layout <- Reduce(modify_list, layouts, p$layout)
295296
p$source <- ensure_one(plots, "source")
296297
p$config <- ensure_one(plots, "config")
297298
p$highlight <- ensure_one(plots, "highlight")
@@ -338,14 +339,18 @@ dots2plots <- function(...) {
338339
# helper function that warns if more than one plot-level attribute
339340
# has been specified in a list of plots (and returning that attribute)
340341
ensure_one <- function(plots, attr) {
341-
attrs <- lapply(plots, "[", attr)
342+
attrs <- Filter(Negate(is.null), lapply(plots, "[[", attr))
343+
if (length(attrs) == 0) {
344+
warning("No ", attr, " found", call. = FALSE)
345+
return (NULL)
346+
}
342347
for (i in seq_along(attrs)) {
343348
if (!identical(attrs[[1]], attrs[[i]])) {
344349
warning("Can only have one: ", attr, call. = FALSE)
345350
break
346351
}
347352
}
348-
attrs[[length(attrs)]][[1]]
353+
attrs[[length(attrs)]]
349354
}
350355

351356

@@ -399,7 +404,7 @@ get_domains <- function(nplots = 1, nrows = 1, margins = 0.01,
399404

400405
list2df <- function(x, nms) {
401406
#stopifnot(length(unique(sapply(x, length))) == 1)
402-
m <- if (length(x) == 1) t(x[[1]]) else Reduce(rbind, x)
407+
m <- if (length(x) == 1) t(x[[1]]) else do.call(rbind, x)
403408
row.names(m) <- NULL
404409
df <- data.frame(m)
405410
if (!missing(nms)) setNames(df, nms) else df

R/sysdata.rda

14.2 KB
Binary file not shown.

inst/docker/Dockerfile.vtest

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# ------------------------------------------------------------------------------
2-
# Remove VMODE to run vdiffr::manage_cases()
31
# $ docker build -t cpsievert/plotly-vtest .
42
# $ docker run -e VMODE="ci" -v $(pwd):/home/plotly --privileged -p 3838:3838 cpsievert/plotly-vtest
53
# ------------------------------------------------------------------------------
@@ -92,6 +90,9 @@ RUN chmod 777 /usr/bin/orca
9290
ENV VDIFFR=true
9391
EXPOSE 3838
9492

93+
RUN R -e "install.packages('assertthat')"
94+
RUN R -e "install.packages('testthat')"
95+
ARG CRANCACHE=1
9596
RUN R -e "update.packages(ask=FALSE)"
9697

9798
# install any new dependencies, then either manage cases (the default) or run tests

inst/examples/shiny/drill_down/app.R

+156
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
library(shiny)
2+
library(plotly)
3+
library(dplyr)
4+
5+
data(sales, package = "plotlyBook")
6+
categories <- unique(sales$category)
7+
sub_categories <- unique(sales$sub_category)
8+
ids <- unique(sales$id)
9+
10+
ui <- fluidPage(
11+
uiOutput("history"),
12+
plotlyOutput("bars", height = 200),
13+
plotlyOutput("lines", height = 300)
14+
)
15+
16+
server <- function(input, output, session) {
17+
# These reactive values keep track of the drilldown state
18+
# (NULL means inactive)
19+
drills <- reactiveValues(
20+
category = NULL,
21+
sub_category = NULL,
22+
id = NULL
23+
)
24+
# filter the data based on active drill-downs
25+
# also create a column, value, which keeps track of which
26+
# variable we're interested in
27+
sales_data <- reactive({
28+
if (!length(drills$category)) {
29+
return(mutate(sales, value = category))
30+
}
31+
sales <- filter(sales, category %in% drills$category)
32+
if (!length(drills$sub_category)) {
33+
return(mutate(sales, value = sub_category))
34+
}
35+
sales <- filter(sales, sub_category %in% drills$sub_category)
36+
mutate(sales, value = id)
37+
})
38+
39+
# bar chart of sales by 'current level of category'
40+
output$bars <- renderPlotly({
41+
d <- count(sales_data(), value, wt = sales)
42+
43+
p <- plot_ly(d, x = ~value, y = ~n, source = "bars") %>%
44+
layout(
45+
yaxis = list(title = "Total Sales"),
46+
xaxis = list(title = "")
47+
)
48+
49+
if (!length(drills$sub_category)) {
50+
add_bars(p, color = ~value)
51+
} else if (!length(drills$id)) {
52+
add_bars(p) %>%
53+
layout(
54+
hovermode = "x",
55+
xaxis = list(showticklabels = FALSE)
56+
)
57+
} else {
58+
# add a visual cue of which ID is selected
59+
add_bars(p) %>%
60+
filter(value %in% drills$id) %>%
61+
add_bars(color = I("black")) %>%
62+
layout(
63+
hovermode = "x", xaxis = list(showticklabels = FALSE),
64+
showlegend = FALSE, barmode = "overlay"
65+
)
66+
}
67+
})
68+
69+
# time-series chart of the sales
70+
output$lines <- renderPlotly({
71+
p <- if (!length(drills$sub_category)) {
72+
sales_data() %>%
73+
count(order_date, value, wt = sales) %>%
74+
plot_ly(x = ~order_date, y = ~n) %>%
75+
add_lines(color = ~value)
76+
} else if (!length(drills$id)) {
77+
sales_data() %>%
78+
count(order_date, wt = sales) %>%
79+
plot_ly(x = ~order_date, y = ~n) %>%
80+
add_lines()
81+
} else {
82+
sales_data() %>%
83+
filter(id %in% drills$id) %>%
84+
select(-value) %>%
85+
plot_ly() %>%
86+
add_table()
87+
}
88+
p %>%
89+
layout(
90+
yaxis = list(title = "Total Sales"),
91+
xaxis = list(title = "")
92+
)
93+
})
94+
95+
# control the state of the drilldown by clicking the bar graph
96+
observeEvent(event_data("plotly_click", source = "bars"), {
97+
x <- event_data("plotly_click", source = "bars")$x
98+
if (!length(x)) return()
99+
100+
if (!length(drills$category)) {
101+
drills$category <- x
102+
} else if (!length(drills$sub_category)) {
103+
drills$sub_category <- x
104+
} else {
105+
drills$id <- x
106+
}
107+
})
108+
109+
# populate a `selectInput()` for each active drilldown
110+
output$history <- renderUI({
111+
if (!length(drills$category)) return("Click the bar chart to drilldown")
112+
categoryInput <- selectInput(
113+
"category", "Category",
114+
choices = categories, selected = drills$category
115+
)
116+
if (!length(drills$sub_category)) return(categoryInput)
117+
sd <- filter(sales, category %in% drills$category)
118+
subCategoryInput <- selectInput(
119+
"sub_category", "Sub-category",
120+
choices = unique(sd$sub_category),
121+
selected = drills$sub_category
122+
)
123+
if (!length(drills$id)) {
124+
return(fluidRow(
125+
column(3, categoryInput),
126+
column(3, subCategoryInput)
127+
))
128+
}
129+
sd <- filter(sd, sub_category %in% drills$sub_category)
130+
idInput <- selectInput(
131+
"id", "Product ID",
132+
choices = unique(sd$id), selected = drills$id
133+
)
134+
fluidRow(
135+
column(3, categoryInput),
136+
column(3, subCategoryInput),
137+
column(3, idInput)
138+
)
139+
})
140+
141+
# control the state of the drilldown via the `selectInput()`s
142+
observeEvent(input$category, {
143+
drills$category <- input$category
144+
drills$sub_category <- NULL
145+
drills$id <- NULL
146+
})
147+
observeEvent(input$sub_category, {
148+
drills$sub_category <- input$sub_category
149+
drills$id <- NULL
150+
})
151+
observeEvent(input$id, {
152+
drills$id <- input$id
153+
})
154+
}
155+
156+
shinyApp(ui, server)

inst/examples/shiny/event_data/tests/mytest-expected/001.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,9 @@
427427
},
428428
{
429429
"name": "plotly-htmlwidgets-css",
430-
"version": "1.46.1",
430+
"version": "1.48.3",
431431
"src": {
432-
"href": "plotly-htmlwidgets-css-1.46.1"
432+
"href": "plotly-htmlwidgets-css-1.48.3"
433433
},
434434
"meta": null,
435435
"script": null,
@@ -440,9 +440,9 @@
440440
},
441441
{
442442
"name": "plotly-main",
443-
"version": "1.46.1",
443+
"version": "1.48.3",
444444
"src": {
445-
"href": "plotly-main-1.46.1"
445+
"href": "plotly-main-1.48.3"
446446
},
447447
"meta": null,
448448
"script": "plotly-latest.min.js",

inst/examples/shiny/event_data/tests/mytest-expected/002.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -444,9 +444,9 @@
444444
},
445445
{
446446
"name": "plotly-htmlwidgets-css",
447-
"version": "1.46.1",
447+
"version": "1.48.3",
448448
"src": {
449-
"href": "plotly-htmlwidgets-css-1.46.1"
449+
"href": "plotly-htmlwidgets-css-1.48.3"
450450
},
451451
"meta": null,
452452
"script": null,
@@ -457,9 +457,9 @@
457457
},
458458
{
459459
"name": "plotly-main",
460-
"version": "1.46.1",
460+
"version": "1.48.3",
461461
"src": {
462-
"href": "plotly-main-1.46.1"
462+
"href": "plotly-main-1.48.3"
463463
},
464464
"meta": null,
465465
"script": "plotly-latest.min.js",

0 commit comments

Comments
 (0)