Skip to content

Commit

Permalink
wip upgrade to plotly.js 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cpsievert committed Jun 8, 2021
1 parent 9fe33eb commit bca31f3
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 28 deletions.
2 changes: 1 addition & 1 deletion R/plotly.R
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ typedArrayPolyfill <- function() {
plotlyMainBundle <- function() {
htmltools::htmlDependency(
name = "plotly-main",
version = "1.57.1",
version = "2.0.0",
package = "plotly",
src = dependency_dir("plotlyjs"),
script = "plotly-latest.min.js",
Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
1 change: 1 addition & 0 deletions inst/examples/shiny/event_data/tests/shinytest/mytest.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
library(shinytest)
app <- ShinyDriver$new("../../", shinyOptions = list(display.mode = "normal"))
app$snapshotInit("mytest")

Expand Down
2 changes: 1 addition & 1 deletion inst/htmlwidgets/lib/plotlyjs/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2020 Plotly, Inc
Copyright (c) 2021 Plotly, Inc

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion inst/htmlwidgets/lib/plotlyjs/locales/cs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 15 additions & 18 deletions inst/htmlwidgets/lib/plotlyjs/plotly-latest.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions inst/htmlwidgets/plotly.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ HTMLWidgets.widget({
// if no plot exists yet, create one with a particular configuration
if (!instance.plotly) {

var plot = Plotly.plot(graphDiv, x);
var plot = Plotly.newPlot(graphDiv, x);
instance.plotly = true;

} else {
Expand All @@ -173,7 +173,7 @@ HTMLWidgets.widget({
// TODO: why is this necessary to get crosstalk working?
graphDiv.data = undefined;
graphDiv.layout = undefined;
var plot = Plotly.plot(graphDiv, x);
var plot = Plotly.newPlot(graphDiv, x);
}

// Trigger plotly.js calls defined via `plotlyProxy()`
Expand Down
16 changes: 11 additions & 5 deletions inst/plotlyjs.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ tmp <- tempfile(fileext = ".zip")
download.file(zip, tmp)
unzip(tmp)

# TODO: patch source to add back in phantomjs support
# https://github.com/plotly/plotly.js/pull/5380/files#diff-459a89970d7ac2d1323f78c770d768ecbbfb9f698b0d1e25e8010e0eb73f56edR12-R14

# update the default bundle
file.copy(
Sys.glob("*plotly.js*/dist/plotly.min.js"),
Expand All @@ -32,11 +35,14 @@ file.copy(
file.path("inst/htmlwidgets/lib/plotlyjs/locales", sub("^plotly-locale-", "", basename(locales))),
overwrite = TRUE
)
# update typed array polyfill
download.file(
"https://raw.githubusercontent.com/plotly/plotly.js/master/dist/extras/typedarray.min.js",
"inst/htmlwidgets/lib/typedarray/typedarray.min.js"
)
# plotly.js used to bundle a typedarray polyfill to support older browsers,
# but v2 drops support for them, so it no longer includes this polyfill
# Hopefully, we can continue to get away with using the pre-v2 polyfill
# to support shinytest/phantomjs
#download.file(
# "https://raw.githubusercontent.com/plotly/plotly.js/master/dist/extras/typedarray.min.js",
# "inst/htmlwidgets/lib/typedarray/typedarray.min.js"
#)

# update the plot schema
Schema <- jsonlite::fromJSON(Sys.glob("*plotly.js*/dist/plot-schema.json"))
Expand Down

0 comments on commit bca31f3

Please sign in to comment.