diff --git a/.Rbuildignore b/.Rbuildignore index cd3d2eba53..63e0d2b162 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -20,3 +20,4 @@ revdep/ README.Rmd abbvie.R ^\.httr-oauth$ +^\.github$ diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000000..2d19fc766d --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +*.html diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 0000000000..ac89eadf42 --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,143 @@ +# 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"} + + 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 Linux sysdeps + if: runner.os == 'Linux' + run: | + pak::local_system_requirements(execute = TRUE) + pak::pkg_system_requirements("rcmdcheck", execute = TRUE) + shell: Rscript {0} + + - name: Install dependencies + run: | + if (Sys.info()[['sysname']] == 'Darwin') options(pkgType = 'mac.binary') + pak::local_install_dev_deps(upgrade = FALSE) + pak::pkg_install("rcmdcheck") + shell: Rscript {0} + + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Install kaleido + if: matrix.config.visual_tests == true + run: | + sudo chown -R $UID $CONDA # https://github.com/nextstrain/conda/issues/5 + Rscript -e "reticulate::install_miniconda()" + Rscript -e "reticulate::conda_install('r-reticulate', 'python-kaleido')" + Rscript -e "reticulate::conda_install('r-reticulate', 'plotly', channel = 'plotly')" + Rscript -e "reticulate::use_miniconda('r-reticulate')" + + - name: Install shinytest deps + if: matrix.config.shinytest == true + run: | + Rscript -e 'shinytest::installDependencies()' + R CMD install . + shell: bash + + # Run test() before R CMD check since, for some reason, rcmdcheck::rcmdcheck() skips vdiffr tests + - name: Run Tests + run: | + options(crayon.enabled = TRUE, testthat.progress.max_fails=1000) + 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 diff --git a/.gitignore b/.gitignore index ccb5eab81d..72c3ccb16a 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,3 @@ revdep/ travis_debug.R .httr-oauth tests/testthat/Rplots.pdf -inst/examples/shiny/event_data/tests/shinytest/mytest-current/ diff --git a/DESCRIPTION b/DESCRIPTION index 5e98212cbc..003d4f97e5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: plotly Title: Create Interactive Web Graphics via 'plotly.js' -Version: 4.9.4.3 +Version: 4.10.0.9001 Authors@R: c(person("Carson", "Sievert", role = c("aut", "cre"), email = "cpsievert1@gmail.com", comment = c(ORCID = "0000-0002-4958-2844")), person("Chris", "Parmer", role = "aut", @@ -20,8 +20,8 @@ Authors@R: c(person("Carson", "Sievert", role = c("aut", "cre"), person("Plotly Technologies Inc.", role = "cph")) License: MIT + file LICENSE Description: Create interactive web graphics from 'ggplot2' graphs and/or a custom interface to the (MIT-licensed) JavaScript library 'plotly.js' inspired by the grammar of graphics. -URL: https://plotly-r.com, https://github.com/ropensci/plotly#readme, https://plotly.com/r/ -BugReports: https://github.com/ropensci/plotly/issues +URL: https://plotly-r.com, https://github.com/plotly/plotly.R, https://plotly.com/r/ +BugReports: https://github.com/plotly/plotly.R/issues Depends: R (>= 3.2.0), ggplot2 (>= 3.0.0) @@ -36,7 +36,7 @@ Imports: base64enc, htmltools (>= 0.3.6), htmlwidgets (>= 1.5.2.9001), - tidyr, + tidyr (>= 1.0.0), RColorBrewer, dplyr, vctrs, @@ -53,6 +53,7 @@ Suggests: hexbin, ggthemes, GGally, + ggalluvial, testthat, knitr, devtools, @@ -60,25 +61,23 @@ Suggests: shinytest (>= 1.3.0), curl, rmarkdown, - vdiffr, Cairo, broom, webshot, listviewer, dendextend, - sf, maptools, rgeos, + sf, png, IRdisplay, processx, plotlyGeoAssets, forcats, - palmerpenguins + palmerpenguins, + rversions, + reticulate LazyData: true RoxygenNote: 7.1.2 Encoding: UTF-8 Roxygen: list(markdown = TRUE) -Remotes: - rstudio/thematic, - Displayr/htmlwidgets diff --git a/NAMESPACE b/NAMESPACE index 0411fd601d..25291e11f7 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -34,8 +34,10 @@ S3method(print,api) S3method(print,api_grid) S3method(print,api_grid_local) S3method(print,api_plot) +S3method(print,kaleidoScope) S3method(print,plotly_data) S3method(to_basic,GeomAbline) +S3method(to_basic,GeomAlluvium) S3method(to_basic,GeomAnnotationMap) S3method(to_basic,GeomArea) S3method(to_basic,GeomBoxplot) @@ -47,6 +49,7 @@ S3method(to_basic,GeomDensity2d) S3method(to_basic,GeomDotplot) S3method(to_basic,GeomErrorbar) S3method(to_basic,GeomErrorbarh) +S3method(to_basic,GeomFunction) S3method(to_basic,GeomHex) S3method(to_basic,GeomHline) S3method(to_basic,GeomJitter) @@ -65,6 +68,7 @@ S3method(to_basic,GeomSf) S3method(to_basic,GeomSmooth) S3method(to_basic,GeomSpoke) S3method(to_basic,GeomStep) +S3method(to_basic,GeomStratum) S3method(to_basic,GeomTile) S3method(to_basic,GeomViolin) S3method(to_basic,GeomVline) @@ -136,6 +140,7 @@ export(hide_guides) export(hide_legend) export(highlight) export(highlight_key) +export(kaleido) export(knit_print.api_grid) export(knit_print.api_grid_local) export(knit_print.api_plot) @@ -168,6 +173,7 @@ export(remove_typedarray_polyfill) export(rename) export(rename_) export(renderPlotly) +export(save_image) export(schema) export(select) export(select_) @@ -251,6 +257,7 @@ importFrom(purrr,transpose) importFrom(rlang,"!!!") importFrom(rlang,"!!") importFrom(rlang,eval_tidy) +importFrom(rlang,is_na) importFrom(stats,complete.cases) importFrom(stats,is.leaf) importFrom(stats,quantile) @@ -260,6 +267,7 @@ importFrom(tidyr,unnest) importFrom(tools,file_ext) importFrom(tools,file_path_sans_ext) importFrom(utils,browseURL) +importFrom(utils,capture.output) importFrom(utils,data) importFrom(utils,file.edit) importFrom(utils,getFromNamespace) diff --git a/NEWS.md b/NEWS.md index a4ca87d73e..8401d34223 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,48 +1,60 @@ -# 4.9.2.1 +# 4.10.0.9000 -This is minor patch release with a few minor bug fixes and updates test expectations in anticipation of new R 4.0 defaults. +## Changes to plotly.js -## BUG FIXES +* This version of the R package upgrades the version of the underlying plotly.js library from v2.5.1 to v2.11.1. This includes many bug fixes and improvements. The [plotly.js release page](https://github.com/plotly/plotly.js/releases) has the full list of changes. -* `plot_mapbox()` now correctly defaults to a scattermapbox trace (unless z is present, then it defaults to choroplethmapbox) (#1702). -* `ggplotly()` now correctly resolves overlapping axis tick text in `coord_sf()` (#1673). -* A false-positive warning is no longer thrown when attempting to cast `toWebGL()` (#1569). +## New features -# 4.9.2 +* `ggplotly()` now supports the `{ggalluvial}` package. (#2061, thanks @moutikabdessabour) +* `highlight()` now supports `on="plotly_selecting"`, enabling client-side linked brushing via mouse click+drag (no mouse-up event required, as with `on="plotly_selected"`). (#1280) -## Changes to plotly.js +## Bug fixes -* This version of the R package upgrades the version of the underlying plotly.js library from v1.49.4 to v1.52.2. This includes many bug fixes, improvements, as well as 2 new trace types: `treemap` and `image`. The [plotly.js release page](https://github.com/plotly/plotly.js/releases) has the full list of changes. +* `ggplotly()` now converts `stat_ecdf()` properly. (#2065) +* `ggplotly()` now correctly handles `geom_tile()` with no `fill` aesthetic. (#2063) +* `ggplotly()` now respects `guide(aes = "none")` (e.g., `guide(fill = "none")`) when constructing legend entries. (#2067) +* Fixed an issue with translating `GGally::ggcorr()` via `ggplotly()`. (#2012) +* Fixed an issue where clearing a crosstalk filter would raise an error in the JS console (#2087) +* Fixed an issue where `map_color()` would throw an error on R 4.2 (#2131) -## IMPROVEMENTS +## Improvements -* The `add_image()` function was added to make it easier to create image traces via `raster` objects. +* `ggplotly()` does not issue warnings with `options(warnPartialMatchArgs = TRUE)` any longer. (#2046, thanks @bersbersbers) +* `ggplotly()` does not issue warnings related to use of deprecated `tidyr::gather_()` in internals. (#2125, thanks @simonpcouch) -## BUG FIXES +# 4.10.0 -* `add_sf()`/`geom_sf()` now correctly handle geometry columns that are named something other than `"geometry"` (#1659). -* Specifying an english locale no longer results in error (#1686). +## Breaking changes in JavaScript API -# 4.9.1 +* This version of the R package upgrades the version of the underlying plotly.js library from v1.57.1 to v2.5.1. This includes many breaking changes, bug fixes, and improvements to the underlying JavaScript library. Most of the breaking changes are summarized in [this announcement of the 2.0 release](https://community.plotly.com/t/announcing-plotly-js-2-0/53675), but [see here](https://github.com/plotly/plotly.js/blob/HEAD/CHANGELOG.md) for the full changelog. -## Changes to plotly.js +## Breaking changes in R API -* This version of the R package upgrades the version of the underlying plotly.js library from v1.46.1 to v1.49.4. The [plotly.js release page](https://github.com/plotly/plotly.js/releases) has the full list of changes. +* `ggplotly()` now uses the `layout.legend.title` (instead of `layout.annotations`) plotly.js API to convert guides for discrete scales. (#1961) +* `renderPlotly()` now uses `Plotly.react()` (instead of `Plotly.newPlot()`) to redraw when `layout(transition = )` is specified. This makes it possible/easier to implement a smooth transitions when `renderPlotly()` gets re-executed. (#2001) -## IMPROVEMENTS +## New Features -* `event_data()` gains support for the `plotly_sunburstclick` event (#1648) +* Added new functions for static image exporting via the [kaleido python package](https://github.com/plotly/Kaleido), namely `save_image()` and `kaleido()`. See `help(save_image, package = "plotly")` for installation info and example usage. (#1971) + +## Improvements + +* `ggplotly()` now better positions axis titles for `facet_wrap()`/`facet_grid()`. (#1975) + +# 4.9.4.1 ## BUG FIXES -======= -# 4.9.3.9000 +* Fixes a bug in `ggplotly()` with `{crosstalk}` and `{ggplot2}` v3.3.4 (#1952). + +# 4.9.4 ## BUG FIXES * Duplicate `highlight(selectize=T)` dropdowns are no longer rendered in Shiny (#1936). * `group_by.plotly()` now properly retains crosstalk information across `{dplyr}` versions (#1920). -* Adds fixes in `ggplotly()` for the upcoming `{ggplot2}` >3.3.3 release (#1952). +* Adds fixes in `ggplotly()` for the upcoming `{ggplot2}` v3.3.4 release (#1952). * Fixes some issues with `name` and `frames` when both attributes are specified. (#1903 and #1618). # 4.9.3 @@ -61,9 +73,7 @@ This is minor patch release with a few minor bug fixes and updates test expectat * All HTTP requests are now retried upon failure (#1656, @jameslamb). -* R linebreaks (`\n`) in _factor labels_ are now translated to HTML linebreaks (`
`), too. Before, this conversion was only done for colums of type character. ([#1700](https://github.com/ropensci/plotly/pull/1700), @salim-b). - -* R linebreaks (`\n`) in _factor labels_ are now translated to HTML linebreaks (`
`), too. Before, this conversion was only done for colums of type character. ([#1700](https://github.com/ropensci/plotly/pull/1700), @salim-b) +* R linebreaks (`\n`) in _factor labels_ are now translated to HTML linebreaks (`
`), too. Before, this conversion was only done for colums of type character. ([#1700](https://github.com/plotly/plotly.R/pull/1700), @salim-b). ## BUG FIXES @@ -133,7 +143,7 @@ This is minor patch release with a few minor bug fixes and updates test expectat ## NEW FEATURES & IMPROVEMENTS -* Several new features and improvements related to accessing plotly.js events in shiny (learn more about them in this RStudio [webinar](https://rstudio.com/resources/webinars/accessing-and-responding-to-plotly-events-in-shiny/)): +* Several new features and improvements related to accessing plotly.js events in shiny (learn more about them in this RStudio [webinar](https://www.rstudio.com/resources/webinars/accessing-and-responding-to-plotly-events-in-shiny/)): * The `event` argument of the `event_data()` function now supports the following events: `plotly_selecting`, `plotly_brushed`, `plotly_brushing`, `plotly_restyle`, `plotly_legendclick`, `plotly_legenddoubleclick`, `plotly_clickannotation`, `plotly_afterplot`, `plotly_doubleclick`, `plotly_deselect`, `plotly_unhover`. For examples, see `plotly_example("shiny", "event_data")`, `plotly_example("shiny", "event_data_legends")`, and `plotly_example("shiny", "event_data_annotation")`, * New `event_register()` and `event_unregister()` functions for declaring which events to transmit over the wire (i.e., from the browser to the shiny server). Events that are likely to have large overhead are not registered by default, so you'll need to register these: `plotly_selecting`, `plotly_unhover`, `plotly_restyle`, `plotly_legendclick`, and `plotly_legenddoubleclick`. * A new `priority` argument. By setting `priority='event'`, the `event` is treated like a true event: any reactive expression using the `event` becomes invalidated (regardless of whether the input values has changed). For an example, see `plotly_example("shiny", "event_priority")`. @@ -197,7 +207,7 @@ This is minor patch release with a few minor bug fixes and updates test expectat ### Other improvements relevant for all **plotly** objects -* LaTeX rendering via MathJax is now supported and the new `TeX()` function may be used to flag a character vector as LaTeX (#375). Use the new `mathjax` argument in `config()` to specify either external (`mathjax="cdn"`) or local (`mathjax="local"`) MathJaX. If `"cdn"`, mathjax is loaded externally (meaning an internet connection is needed for TeX rendering). If `"local"`, the PLOTLY_MATHJAX_PATH environment variable must be set to the location (a local file path) of MathJax. IMPORTANT: **plotly** uses SVG-based mathjax rendering which doesn't play nicely with HTML-based rendering (e.g., **rmarkdown** documents and **shiny** apps). To leverage both types of rendering, you must `