Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to plotly.js 2.0 #1967

Merged
merged 34 commits into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d9c7ee0
wip upgrade to plotly.js 2.0
cpsievert Jun 21, 2021
cda64ad
patch plotly.js source to support phantomjs/shinytest
cpsievert Jun 21, 2021
d5982ff
bump mathjax version
cpsievert Jun 21, 2021
f52c111
use npm instead of yarn
cpsievert Jun 21, 2021
cd33241
make geom_bar() default to textposition='none'; approve new vdiffr 0.…
cpsievert Jun 21, 2021
32f491b
Migrate to vdiffr 1.0
cpsievert Jun 21, 2021
3435fbb
Use layout.legend.title over layout.annotations to when converting gu…
cpsievert Jun 21, 2021
d541471
wip migrate to gha
cpsievert Jun 21, 2021
1216874
try npm install
cpsievert Jun 21, 2021
b0f7d16
setup node
cpsievert Jun 21, 2021
e621db1
use recommended node version
cpsievert Jun 21, 2021
a12ad8a
try mac instead
cpsievert Jun 21, 2021
ac249b8
install phantomjs; various cleanup
cpsievert Jun 21, 2021
057fe1f
intentionally break a visual test
cpsievert Jun 21, 2021
88d3c45
fix
cpsievert Jun 21, 2021
38e1bdd
use thematic's approach to testing
cpsievert Jun 21, 2021
177935b
bump version
cpsievert Jun 21, 2021
b056974
Merge branch 'master' into plotlyjs-2.0
cpsievert Jun 21, 2021
bce7053
regenerate snapshots
cpsievert Jun 21, 2021
d37f405
map secrets to env variables
cpsievert Jun 21, 2021
af624bb
accept new gha baselines
cpsievert Jun 21, 2021
f1c39a1
whoops
cpsievert Jun 21, 2021
8de5521
hmm
cpsievert Jun 21, 2021
eed311f
approve shinytest baseline
cpsievert Jun 21, 2021
362b6a4
intentionally break a visual test
cpsievert Jun 21, 2021
6b563bf
always upload
cpsievert Jun 21, 2021
ec40dd8
revert change; new baselines
cpsievert Jun 21, 2021
bd63208
Remove the vdiffr dependency and use testthat snaphots directly
cpsievert Jun 21, 2021
8bd4613
More obvious env var naming
cpsievert Jun 21, 2021
e2fae51
more gha details
cpsievert Jun 21, 2021
be22619
always upload
cpsievert Jun 21, 2021
aa44563
new snaps
cpsievert Jun 21, 2021
a4e306c
intentionally break a visual test (again)
cpsievert Jun 21, 2021
e7c86bb
Revert "intentionally break a visual test (again)"
cpsievert Jun 21, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ revdep/
README.Rmd
abbvie.R
^\.httr-oauth$
^\.github$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
146 changes: 146 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# NOTE: This workflow is overkill for most R packages
# check-standard.yaml is likely a better choice
# usethis::use_github_action("check-standard") will install it.
#
# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag.
# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions
on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master

name: R-CMD-check

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macOS-latest, r: 'release', visual_tests: true, node: "14.x", shinytest: true}
- {os: windows-latest, r: 'release'}
- {os: windows-latest, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/latest"}
- {os: ubuntu-18.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", http-user-agent: "R/4.1.0 (ubuntu-18.04) R (4.1.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" }
# vdiffr & shinytest only runs on linux r-release since the results aren't cross-platform
- {os: ubuntu-18.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
- {os: ubuntu-18.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
- {os: ubuntu-18.04, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
- {os: ubuntu-18.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
- {os: ubuntu-18.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}

env:
RSPM: ${{ matrix.config.rspm }}
VISUAL_TESTS: ${{ matrix.config.visual_tests }}
SHINYTEST: ${{ matrix.config.shinytest }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
MAPBOX_TOKEN: ${{ secrets.MAPBOX_TOKEN }}
plotly_username: ${{ secrets.PLOTLY_USERNAME }}
plotly_api_key: ${{ secrets.PLOTLY_API_KEY }}

steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@v1
id: install-r
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}

- uses: r-lib/actions/setup-pandoc@v1

- name: Install pak and query dependencies
run: |
install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/")
saveRDS(pak::pkg_deps("local::.", dependencies = TRUE), ".github/r-depends.rds")
shell: Rscript {0}

- name: Restore R package cache
uses: actions/cache@v2
with:
path: |
${{ env.R_LIBS_USER }}/*
!${{ env.R_LIBS_USER }}/pak
key: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1-${{ hashFiles('.github/r-depends.rds') }}
restore-keys: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1-

- name: Install system dependencies
if: runner.os == 'Linux'
run: |
pak::local_system_requirements(execute = TRUE)
pak::pkg_system_requirements("rcmdcheck", execute = TRUE)
shell: Rscript {0}

- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.config.node }}

- name: Install orca
if: matrix.config.visual_tests == true
run: npm install -g [email protected] orca
shell: bash

- name: Install phantomjs
if: matrix.config.shinytest == true
run: |
pak::pak("shinytest")
shinytest::installDependencies()
pak::pak()
shell: Rscript {0}

- name: Install dependencies
run: |
pak::local_install_dev_deps(upgrade = TRUE)
pak::pkg_install("rcmdcheck")
shell: Rscript {0}

- name: Session info
run: |
options(width = 100)
pkgs <- installed.packages()[, "Package"]
sessioninfo::session_info(pkgs, include_base = TRUE)
shell: Rscript {0}

# Run test() before R CMD check since, for some reason, rcmdcheck::rcmdcheck() skips vdiffr tests
- name: Run Tests
run: |
options(crayon.enabled = TRUE)
if (!require(devtools)) pak::pak("devtools")
if (!require(reshape2)) pak::pak("reshape2")
res <- devtools::test()
df <- as.data.frame(res)
if (sum(df$failed) > 0 || any(df$error)) stop("GHA CI tests failed")
shell: Rscript {0}

# Upload the whole pkg since tests where run with devtools::test()
- name: Upload check results
if: always()
uses: actions/upload-artifact@master
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: ./

# Run check with --no-tests since we ran them abve
- name: Check
run: |
options(crayon.enabled = TRUE)
rcmdcheck::rcmdcheck(args = c("--no-tests", "--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
shell: Rscript {0}

#- name: Show testthat output
# if: always()
# run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
# shell: bash

- name: Don't use tar from old Rtools to store the cache
if: ${{ runner.os == 'Windows' && startsWith(steps.install-r.outputs.installed-r-version, '3.6' ) }}
shell: bash
run: echo "C:/Program Files/Git/usr/bin" >> $GITHUB_PATH
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ revdep/
travis_debug.R
.httr-oauth
tests/testthat/Rplots.pdf
inst/examples/shiny/event_data/tests/shinytest/mytest-current/
36 changes: 0 additions & 36 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ Suggests:
shinytest (>= 1.3.0),
curl,
rmarkdown,
vdiffr,
Cairo,
broom,
webshot,
Expand All @@ -74,7 +73,8 @@ Suggests:
processx,
plotlyGeoAssets,
forcats,
palmerpenguins
palmerpenguins,
rversions
LazyData: true
RoxygenNote: 7.1.1
Encoding: UTF-8
Expand Down
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# 4.9.4.9000

## Changes to plotly.js

* This version of the R package upgrades the version of the underlying plotly.js library from v1.57.1 to v2.0.0. This includes many breaking changes, bug fixes, and improvements to the underlying JavaScript library. The [plotly.js release page](https://github.com/plotly/plotly.js/releases) has the full list of changes.

## Breaking changes

* `ggplotly()` now uses the `layout.legend.title` (instead of `layout.annotations`) plotly.js API to convert guides for discrete scales. (#1961)

# 4.9.4.1

Expand Down
26 changes: 6 additions & 20 deletions R/ggplotly.R
Original file line number Diff line number Diff line change
Expand Up @@ -999,26 +999,12 @@ gg2list <- function(p, width = NULL, height = NULL,
}
traces <- c(traces, colorbar)

# legend title annotation - https://github.com/plotly/plotly.js/issues/276
if (isTRUE(gglayout$showlegend)) {
legendTitles <- compact(lapply(gdefs, function(g) if (inherits(g, "legend")) g$title else NULL))
legendTitle <- paste(legendTitles, collapse = br())
titleAnnotation <- make_label(
legendTitle,
x = gglayout$legend$x %||% 1.02,
y = gglayout$legend$y %||% 1,
theme$legend.title,
xanchor = "left",
yanchor = "bottom",
# just so the R client knows this is a title
legendTitle = TRUE
)
gglayout$annotations <- c(gglayout$annotations, titleAnnotation)
# adjust the height of the legend to accomodate for the title
# this assumes the legend always appears below colorbars
gglayout$legend$y <- (gglayout$legend$y %||% 1) -
length(legendTitles) * unitConvert(theme$legend.title$size, "npc", "height")
}
legendTitles <- compact(lapply(gdefs, function(g) if (inherits(g, "legend")) g$title else NULL))
legendTitle <- paste(legendTitles, collapse = br())
gglayout$legend$title <- list(
text = legendTitle,
font = text2font(theme$legend.title)
)
}

# flip x/y in traces for flipped coordinates
Expand Down
5 changes: 5 additions & 0 deletions R/layers2traces.R
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,11 @@ geom2trace.GeomBar <- function(data, params, p) {
frame = data[["frame"]],
ids = data[["ids"]],
type = "bar",
# plotly.js v2.0 changed default to textposition='auto', meaning
# text will display by default, which makes sense for plot_ly() maybe,
# but not ggplotly()
# https://github.com/plotly/orca/issues/374
textposition = "none",
marker = list(
autocolorscale = FALSE,
color = toRGB(
Expand Down
2 changes: 1 addition & 1 deletion R/mathjax.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ is.TeX <- function(x) {
mathjax_cdn <- function() {
htmltools::htmlDependency(
name = "mathjax",
version = "2.7.4",
version = "2.7.5",
package = "plotly",
src = dependency_dir("mathjax"),
script = "cdn.js"
Expand Down
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.
3 changes: 0 additions & 3 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -845,9 +845,6 @@ verify_showlegend <- function(p) {
# this attribute should be set in hide_legend()
# it ensures that "legend titles" go away in addition to showlegend = FALSE
if (isTRUE(p$x$.hideLegend)) {
ann <- p$x$layout$annotations
is_title <- vapply(ann, function(x) isTRUE(x$legendTitle), logical(1))
p$x$layout$annotations <- ann[!is_title]
p$x$layout$showlegend <- FALSE
}
show <- vapply(p$x$data, function(x) x$showlegend %||% TRUE, logical(1))
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@

<img src="man/figures/plotly.png" width="200" />

[![Build
Status](https://travis-ci.org/ropensci/plotly.png?branch=master)](https://travis-ci.org/ropensci/plotly)
<!-- badges: start -->
[![R-CMD-check](https://github.com/ropensci/plotly/workflows/R-CMD-check/badge.svg)](https://github.com/ropensci/plotly/actions)
[![CRAN
Status](https://www.r-pkg.org/badges/version/plotly)](https://cran.r-project.org/package=plotly)
[![CRAN
Downloads](https://cranlogs.r-pkg.org/badges/grand-total/plotly)](https://www.rpackages.io/package/plotly)
[![monthly](https://cranlogs.r-pkg.org/badges/plotly)](https://www.rpackages.io/package/plotly)
<!-- badges: end -->

An R package for creating interactive web graphics via the open source
JavaScript graphing library
Expand All @@ -23,10 +24,10 @@ Install from CRAN:
install.packages("plotly")
```

Or install the latest development version (on GitHub) via devtools:
Or install the latest development version (on GitHub) via `{remotes}`:

``` r
devtools::install_github("ropensci/plotly")
remotes::install_github("ropensci/plotly")
```

## Getting started
Expand Down
Loading