Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cead5d9

Browse filesBrowse files
authored
Merge pull request #1695 from ropensci/v1.52
Upgrade plotly.js to 1.52
2 parents 7f7a60d + cabc57d commit cead5d9
Copy full SHA for cead5d9

File tree

Expand file treeCollapse file tree

407 files changed

+637
-411
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

407 files changed

+637
-411
lines changed

‎NEWS.md

Copy file name to clipboardExpand all lines: NEWS.md
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# 4.9.1.9000
22

3+
## Changes to plotly.js
4+
5+
* This version of the R package upgrades the version of the underlying plotly.js library from v1.49.4 to v1.52.2. The [plotly.js release page](https://github.com/plotly/plotly.js/releases) has the full list of changes.
6+
37
## BUG FIXES
48

59
* `add_sf()`/`geom_sf()` now correctly handle geometry columns that are named something other than `"geometry"` (#1659).

‎R/add.R

Copy file name to clipboardExpand all lines: R/add.R
+38-1Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ add_data <- function(p, data = NULL) {
2424
#' @inheritParams plot_ly
2525
#' @param p a plotly object
2626
#' @param inherit inherit attributes from [plot_ly()]?
27-
#' @param z a numeric matrix
27+
#' @param z a numeric matrix (unless [add_image()], which wants a raster object, see [as.raster()]).
2828
#' @param x the x variable.
2929
#' @param y the y variable.
3030
#' @param text textual labels.
@@ -393,6 +393,43 @@ add_ribbons <- function(p, x = NULL, ymin = NULL, ymax = NULL, ...,
393393
)
394394
}
395395

396+
#' @inheritParams add_trace
397+
#' @rdname add_trace
398+
#' @param colormodel Sets the colormodel for image traces if `z` is not a raster object.
399+
#' If `z` is a raster object (see [as.raster()]), the `'rgba'` colormodel is always used.
400+
#' @export
401+
add_image <- function(p, z = NULL, colormodel = NULL, ..., data = NULL, inherit = TRUE) {
402+
403+
if (inherit) {
404+
z <- z %||% p$x$attrs[[1]][["z"]]
405+
colormodel <- colormodel %||% p$x$attrs[[1]][["colormodel"]]
406+
}
407+
408+
if (inherits(z, "raster")) {
409+
cols <- col2rgb(z, alpha = TRUE)
410+
dims <- c(dim(z), 4)
411+
z <- array(numeric(prod(dims)), dims)
412+
matrix_ <- function(x) {
413+
matrix(x, byrow = TRUE, nrow = dims[1], ncol = dims[2])
414+
}
415+
z[,,1] <- matrix_(cols["red",])
416+
z[,,2] <- matrix_(cols["green",])
417+
z[,,3] <- matrix_(cols["blue",])
418+
z[,,4] <- matrix_(cols["alpha",])
419+
420+
# Throw if we detect another colormodel
421+
if (!identical(colormodel %||% "rgba", "rgba")) {
422+
warning("Passing a raster object to z requires rgba colormodel")
423+
}
424+
colormodel <- "rgba"
425+
}
426+
427+
add_trace(
428+
p, z = z, colormodel = colormodel, ...,
429+
data = data, type = "image"
430+
)
431+
}
432+
396433
#' @inheritParams add_trace
397434
#' @rdname add_trace
398435
#' @param r For polar chart only. Sets the radial coordinates.

‎R/plotly.R

Copy file name to clipboardExpand all lines: R/plotly.R
+21-1Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,15 @@ as_widget <- function(x, ...) {
424424
),
425425
preRenderHook = plotly_build,
426426
dependencies = c(
427+
# phantomjs doesn't support Object.setPrototypeOf() and a
428+
# plotly.js dependency (buffer) uses it to detect TypedArray support.
429+
# Thus, we add a polyfill if this is running in shinytest, but otherwise
430+
# we shouldn't need it because Object.setPrototypeOf() is pretty widely supported
431+
# https://github.com/plotly/plotly.js/issues/4556#issuecomment-583061419
432+
# https://caniuse.com/#search=setPrototypeOf
433+
if (isTRUE(getOption("shiny.testmode"))) {
434+
list(setPrototypeOfPolyfill())
435+
},
427436
list(typedArrayPolyfill()),
428437
crosstalk::crosstalkLibs(),
429438
list(plotlyHtmlwidgetsCSS()),
@@ -432,6 +441,17 @@ as_widget <- function(x, ...) {
432441
)
433442
}
434443

444+
setPrototypeOfPolyfill <- function() {
445+
htmltools::htmlDependency(
446+
name = "setprototypeof",
447+
version = "0.1",
448+
package = "plotly",
449+
src = dependency_dir("setprototypeof"),
450+
script = "setprototypeof.js",
451+
all_files = FALSE
452+
)
453+
}
454+
435455
typedArrayPolyfill <- function() {
436456
htmltools::htmlDependency(
437457
name = "typedarray",
@@ -446,7 +466,7 @@ typedArrayPolyfill <- function() {
446466
plotlyMainBundle <- function() {
447467
htmltools::htmlDependency(
448468
name = "plotly-main",
449-
version = "1.49.4",
469+
version = "1.52.2",
450470
package = "plotly",
451471
src = dependency_dir("plotlyjs"),
452472
script = "plotly-latest.min.js",

‎R/plotly_build.R

Copy file name to clipboardExpand all lines: R/plotly_build.R
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,7 @@ coerce_attr_defaults <- function(trace, layout) {
10331033
if (length(trace[["stroke"]]) && !is.default(trace[["stroke"]])) {
10341034
trace$span <- trace[["span"]] %||% default(I(1))
10351035
}
1036-
if (trace[["type"]] %in% c("sunburst", "pie")) {
1036+
if (trace[["type"]] %in% c("sunburst", "pie", "treemap")) {
10371037
# As of v1.46.1, paper_bgcolor defaults to '#fff' which
10381038
# col2rgb() can't parse, but expands to '#ffffff'
10391039
# https://stackoverflow.com/a/2899224/1583084

‎R/sysdata.rda

Copy file name to clipboard
8.64 KB
Binary file not shown.

‎inst/docker/Dockerfile.vtest

Copy file name to clipboardExpand all lines: inst/docker/Dockerfile.vtest
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ RUN R -e "install.packages('assertthat')"
9494
RUN R -e "install.packages('testthat')"
9595
ARG CRANCACHE=1
9696
RUN R -e "update.packages(ask=FALSE)"
97+
RUN R -e "remotes::install_github('r-lib/vdiffr')"
9798

9899
# install any new dependencies, then either manage cases (the default) or run tests
99100
# note the workaround to get docker to run a proper exit status when there are testthat errors

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

Copy file name to clipboardExpand all lines: inst/examples/shiny/event_data/tests/mytest-expected/001.json
+17-4Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,19 @@
385385

386386
],
387387
"deps": [
388+
{
389+
"name": "setprototypeof",
390+
"version": "0.1",
391+
"src": {
392+
"href": "setprototypeof-0.1"
393+
},
394+
"meta": null,
395+
"script": "setprototypeof.js",
396+
"stylesheet": null,
397+
"head": null,
398+
"attachment": null,
399+
"all_files": false
400+
},
388401
{
389402
"name": "typedarray",
390403
"version": "0.1",
@@ -428,9 +441,9 @@
428441
},
429442
{
430443
"name": "plotly-htmlwidgets-css",
431-
"version": "1.49.4",
444+
"version": "1.52.2",
432445
"src": {
433-
"href": "plotly-htmlwidgets-css-1.49.4"
446+
"href": "plotly-htmlwidgets-css-1.52.2"
434447
},
435448
"meta": null,
436449
"script": null,
@@ -441,9 +454,9 @@
441454
},
442455
{
443456
"name": "plotly-main",
444-
"version": "1.49.4",
457+
"version": "1.52.2",
445458
"src": {
446-
"href": "plotly-main-1.49.4"
459+
"href": "plotly-main-1.52.2"
447460
},
448461
"meta": null,
449462
"script": "plotly-latest.min.js",

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

Copy file name to clipboardExpand all lines: inst/examples/shiny/event_data/tests/mytest-expected/002.json
+17-4Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,19 @@
402402

403403
],
404404
"deps": [
405+
{
406+
"name": "setprototypeof",
407+
"version": "0.1",
408+
"src": {
409+
"href": "setprototypeof-0.1"
410+
},
411+
"meta": null,
412+
"script": "setprototypeof.js",
413+
"stylesheet": null,
414+
"head": null,
415+
"attachment": null,
416+
"all_files": false
417+
},
405418
{
406419
"name": "typedarray",
407420
"version": "0.1",
@@ -445,9 +458,9 @@
445458
},
446459
{
447460
"name": "plotly-htmlwidgets-css",
448-
"version": "1.49.4",
461+
"version": "1.52.2",
449462
"src": {
450-
"href": "plotly-htmlwidgets-css-1.49.4"
463+
"href": "plotly-htmlwidgets-css-1.52.2"
451464
},
452465
"meta": null,
453466
"script": null,
@@ -458,9 +471,9 @@
458471
},
459472
{
460473
"name": "plotly-main",
461-
"version": "1.49.4",
474+
"version": "1.52.2",
462475
"src": {
463-
"href": "plotly-main-1.49.4"
476+
"href": "plotly-main-1.52.2"
464477
},
465478
"meta": null,
466479
"script": "plotly-latest.min.js",

‎inst/examples/shiny/event_data/tests/mytest-expected/003.json

Copy file name to clipboardExpand all lines: inst/examples/shiny/event_data/tests/mytest-expected/003.json
+17-4Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,19 @@
406406

407407
],
408408
"deps": [
409+
{
410+
"name": "setprototypeof",
411+
"version": "0.1",
412+
"src": {
413+
"href": "setprototypeof-0.1"
414+
},
415+
"meta": null,
416+
"script": "setprototypeof.js",
417+
"stylesheet": null,
418+
"head": null,
419+
"attachment": null,
420+
"all_files": false
421+
},
409422
{
410423
"name": "typedarray",
411424
"version": "0.1",
@@ -449,9 +462,9 @@
449462
},
450463
{
451464
"name": "plotly-htmlwidgets-css",
452-
"version": "1.49.4",
465+
"version": "1.52.2",
453466
"src": {
454-
"href": "plotly-htmlwidgets-css-1.49.4"
467+
"href": "plotly-htmlwidgets-css-1.52.2"
455468
},
456469
"meta": null,
457470
"script": null,
@@ -462,9 +475,9 @@
462475
},
463476
{
464477
"name": "plotly-main",
465-
"version": "1.49.4",
478+
"version": "1.52.2",
466479
"src": {
467-
"href": "plotly-main-1.49.4"
480+
"href": "plotly-main-1.52.2"
468481
},
469482
"meta": null,
470483
"script": "plotly-latest.min.js",

‎inst/examples/shiny/event_data/tests/mytest-expected/004.json

Copy file name to clipboardExpand all lines: inst/examples/shiny/event_data/tests/mytest-expected/004.json
+17-4Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,19 @@
407407

408408
],
409409
"deps": [
410+
{
411+
"name": "setprototypeof",
412+
"version": "0.1",
413+
"src": {
414+
"href": "setprototypeof-0.1"
415+
},
416+
"meta": null,
417+
"script": "setprototypeof.js",
418+
"stylesheet": null,
419+
"head": null,
420+
"attachment": null,
421+
"all_files": false
422+
},
410423
{
411424
"name": "typedarray",
412425
"version": "0.1",
@@ -450,9 +463,9 @@
450463
},
451464
{
452465
"name": "plotly-htmlwidgets-css",
453-
"version": "1.49.4",
466+
"version": "1.52.2",
454467
"src": {
455-
"href": "plotly-htmlwidgets-css-1.49.4"
468+
"href": "plotly-htmlwidgets-css-1.52.2"
456469
},
457470
"meta": null,
458471
"script": null,
@@ -463,9 +476,9 @@
463476
},
464477
{
465478
"name": "plotly-main",
466-
"version": "1.49.4",
479+
"version": "1.52.2",
467480
"src": {
468-
"href": "plotly-main-1.49.4"
481+
"href": "plotly-main-1.52.2"
469482
},
470483
"meta": null,
471484
"script": "plotly-latest.min.js",

‎inst/htmlwidgets/lib/plotlyjs/LICENSE

Copy file name to clipboardExpand all lines: inst/htmlwidgets/lib/plotlyjs/LICENSE
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2019 Plotly, Inc
3+
Copyright (c) 2020 Plotly, Inc
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

‎inst/htmlwidgets/lib/plotlyjs/locales/af.js

Copy file name to clipboardExpand all lines: inst/htmlwidgets/lib/plotlyjs/locales/af.js
+1-1Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎inst/htmlwidgets/lib/plotlyjs/locales/am.js

Copy file name to clipboardExpand all lines: inst/htmlwidgets/lib/plotlyjs/locales/am.js
+1-1Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎inst/htmlwidgets/lib/plotlyjs/locales/ar-dz.js

Copy file name to clipboardExpand all lines: inst/htmlwidgets/lib/plotlyjs/locales/ar-dz.js
+1-1Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎inst/htmlwidgets/lib/plotlyjs/locales/ar-eg.js

Copy file name to clipboardExpand all lines: inst/htmlwidgets/lib/plotlyjs/locales/ar-eg.js
+1-1Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎inst/htmlwidgets/lib/plotlyjs/locales/ar.js

Copy file name to clipboardExpand all lines: inst/htmlwidgets/lib/plotlyjs/locales/ar.js
+1-1Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.