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 053e70b

Browse filesBrowse files
committed
patch plotly.js source to support phantomjs/shinytest
reverts part of plotly/plotly.js#5380
1 parent 984dc64 commit 053e70b
Copy full SHA for 053e70b

File tree

12 files changed

+139
-87
lines changed
Filter options

12 files changed

+139
-87
lines changed

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

Copy file name to clipboardExpand all lines: inst/examples/shiny/event_data/tests/shinytest/mytest-expected/001.json
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -439,9 +439,9 @@
439439
},
440440
{
441441
"name": "plotly-htmlwidgets-css",
442-
"version": "1.57.1",
442+
"version": "2.0.0",
443443
"src": {
444-
"href": "plotly-htmlwidgets-css-1.57.1"
444+
"href": "plotly-htmlwidgets-css-2.0.0"
445445
},
446446
"meta": null,
447447
"script": null,
@@ -452,9 +452,9 @@
452452
},
453453
{
454454
"name": "plotly-main",
455-
"version": "1.57.1",
455+
"version": "2.0.0",
456456
"src": {
457-
"href": "plotly-main-1.57.1"
457+
"href": "plotly-main-2.0.0"
458458
},
459459
"meta": null,
460460
"script": "plotly-latest.min.js",
Loading

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

Copy file name to clipboardExpand all lines: inst/examples/shiny/event_data/tests/shinytest/mytest-expected/002.json
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"plotly_afterplot-A": "\"plot\"",
1818
"plotly_click-A": "[{\"curveNumber\":0,\"pointNumber\":7,\"x\":24.4,\"y\":3.19,\"customdata\":\"Merc 240D\"}]",
1919
"plotly_hover-A": null,
20+
"plotly_relayout-A": "{\"width\":962,\"height\":400}",
2021
"plotType": "ggplotly"
2122
},
2223
"output": {
@@ -456,9 +457,9 @@
456457
},
457458
{
458459
"name": "plotly-htmlwidgets-css",
459-
"version": "1.57.1",
460+
"version": "2.0.0",
460461
"src": {
461-
"href": "plotly-htmlwidgets-css-1.57.1"
462+
"href": "plotly-htmlwidgets-css-2.0.0"
462463
},
463464
"meta": null,
464465
"script": null,
@@ -469,9 +470,9 @@
469470
},
470471
{
471472
"name": "plotly-main",
472-
"version": "1.57.1",
473+
"version": "2.0.0",
473474
"src": {
474-
"href": "plotly-main-1.57.1"
475+
"href": "plotly-main-2.0.0"
475476
},
476477
"meta": null,
477478
"script": "plotly-latest.min.js",
Loading

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

Copy file name to clipboardExpand all lines: inst/examples/shiny/event_data/tests/shinytest/mytest-expected/003.json
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"plotly_brushing-A": "{\"x\":[23.95978500551268,25.98332414553473],\"y\":[3.0020072289156627,3.5073743975903615]}",
2020
"plotly_click-A": "[{\"curveNumber\":0,\"pointNumber\":7,\"x\":24.4,\"y\":3.19,\"customdata\":\"Merc 240D\"}]",
2121
"plotly_hover-A": null,
22+
"plotly_relayout-A": "{\"width\":962,\"height\":400}",
2223
"plotly_selected-A": "[{\"curveNumber\":0,\"pointNumber\":7,\"x\":24.4,\"y\":3.19,\"customdata\":\"Merc 240D\"}]",
2324
"plotly_selecting-A": "[{\"curveNumber\":0,\"pointNumber\":7,\"x\":24.4,\"y\":3.19,\"customdata\":\"Merc 240D\"}]",
2425
"plotType": "ggplotly"
@@ -460,9 +461,9 @@
460461
},
461462
{
462463
"name": "plotly-htmlwidgets-css",
463-
"version": "1.57.1",
464+
"version": "2.0.0",
464465
"src": {
465-
"href": "plotly-htmlwidgets-css-1.57.1"
466+
"href": "plotly-htmlwidgets-css-2.0.0"
466467
},
467468
"meta": null,
468469
"script": null,
@@ -473,9 +474,9 @@
473474
},
474475
{
475476
"name": "plotly-main",
476-
"version": "1.57.1",
477+
"version": "2.0.0",
477478
"src": {
478-
"href": "plotly-main-1.57.1"
479+
"href": "plotly-main-2.0.0"
479480
},
480481
"meta": null,
481482
"script": "plotly-latest.min.js",
Loading

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

Copy file name to clipboardExpand all lines: inst/examples/shiny/event_data/tests/shinytest/mytest-expected/004.json
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"plotly_click-A": null,
2121
"plotly_deselect-A": "\"plot\"",
2222
"plotly_hover-A": null,
23+
"plotly_relayout-A": "{\"width\":962,\"height\":400}",
2324
"plotly_selected-A": null,
2425
"plotly_selecting-A": null,
2526
"plotType": "ggplotly"
@@ -461,9 +462,9 @@
461462
},
462463
{
463464
"name": "plotly-htmlwidgets-css",
464-
"version": "1.57.1",
465+
"version": "2.0.0",
465466
"src": {
466-
"href": "plotly-htmlwidgets-css-1.57.1"
467+
"href": "plotly-htmlwidgets-css-2.0.0"
467468
},
468469
"meta": null,
469470
"script": null,
@@ -474,9 +475,9 @@
474475
},
475476
{
476477
"name": "plotly-main",
477-
"version": "1.57.1",
478+
"version": "2.0.0",
478479
"src": {
479-
"href": "plotly-main-1.57.1"
480+
"href": "plotly-main-2.0.0"
480481
},
481482
"meta": null,
482483
"script": "plotly-latest.min.js",
Loading

‎inst/htmlwidgets/lib/plotlyjs/plotly-latest.min.js

Copy file name to clipboardExpand all lines: inst/htmlwidgets/lib/plotlyjs/plotly-latest.min.js
+13-9Lines changed: 13 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎inst/plotlyjs.R

Copy file name to clipboardExpand all lines: inst/plotlyjs.R
-62Lines changed: 0 additions & 62 deletions
This file was deleted.
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
diff --git a/src/lib/array.js b/src/lib/array.js
2+
index 19463675a..470d3d6bf 100644
3+
--- a/src/lib/array.js
4+
+++ b/src/lib/array.js
5+
@@ -2,8 +2,15 @@
6+
7+
var isArray = Array.isArray;
8+
9+
-var ab = ArrayBuffer;
10+
-var dv = DataView;
11+
+// IE9 fallbacks
12+
+
13+
+var ab = (typeof ArrayBuffer === 'undefined' || !ArrayBuffer.isView) ?
14+
+ {isView: function() { return false; }} :
15+
+ ArrayBuffer;
16+
+
17+
+var dv = (typeof DataView === 'undefined') ?
18+
+ function() {} :
19+
+ DataView;
20+
21+
function isTypedArray(a) {
22+
return ab.isView(a) && !(a instanceof dv);

‎tools/update_plotlyjs.R

Copy file name to clipboard
+85Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
library(httr)
2+
library(rprojroot)
3+
4+
# get zip URL to latest plotly.js release
5+
x <- RETRY(
6+
verb = "GET",
7+
url = 'https://api.github.com/repos/plotly/plotly.js/releases/latest',
8+
times = 5,
9+
terminate_on = c(400, 401, 403, 404),
10+
terminate_on_success = TRUE
11+
)
12+
zip <- content(x)$zipball_url
13+
14+
# remember where to copy over assets
15+
pkg_dir <- find_package_root_file()
16+
lib_dir <- find_package_root_file("inst/htmlwidgets/lib/plotlyjs")
17+
patches <- list.files(
18+
find_package_root_file("tools/patches"),
19+
full.names = TRUE
20+
)
21+
22+
# download, patch, and build plotly.js in temp dir
23+
tmpdir <- tempfile()
24+
dir.create(tmpdir)
25+
26+
withr::with_dir(tmpdir, {
27+
# download source
28+
download.file(zip, "plotly-js.zip")
29+
unzip("plotly-js.zip", exdir = "plotly-js")
30+
31+
withr::with_dir(
32+
dir("plotly-js", full.names = TRUE), {
33+
34+
# apply patches
35+
for (patch in patches) {
36+
tryCatch({
37+
message(sprintf("Applying %s", basename(patch)))
38+
system(sprintf("git apply %s", patch))
39+
},
40+
error = function(e) quit(save = "no", status = 1)
41+
)
42+
}
43+
44+
# build
45+
system("yarn install")
46+
system("yarn build")
47+
48+
# copy assets to R package source
49+
file.copy(
50+
"dist/plotly.min.js",
51+
file.path(lib_dir, "plotly-latest.min.js"),
52+
overwrite = TRUE
53+
)
54+
file.copy(
55+
"LICENSE",
56+
file.path(lib_dir, "LICENSE"),
57+
overwrite = TRUE
58+
)
59+
60+
locales <- Sys.glob("dist/plotly-locale-*.js")
61+
file.copy(
62+
locales,
63+
file.path(lib_dir, "locales", sub("^plotly-locale-", "", basename(locales))),
64+
overwrite = TRUE
65+
)
66+
# update plot schema
67+
Schema <- jsonlite::fromJSON(Sys.glob("dist/plot-schema.json"))
68+
withr::with_dir(
69+
pkg_dir, usethis::use_data(Schema, overwrite = TRUE, internal = TRUE)
70+
)
71+
72+
# plotly.js used to bundle a typedarray polyfill to support older browsers,
73+
# but v2 drops support for them, so it no longer includes this polyfill
74+
# Hopefully, we can continue to get away with using the pre-v2 polyfill
75+
# to support shinytest/phantomjs
76+
#download.file(
77+
# "dist/extras/typedarray.min.js",
78+
# "inst/htmlwidgets/lib/typedarray/typedarray.min.js"
79+
#)
80+
81+
message("Update plotlyMainBundle()'s version with ", basename(zip))
82+
83+
})
84+
85+
})

0 commit comments

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