Skip to content

upgrade plotly.js #1450

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

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## NEW FEATURES & IMPROVEMENTS

* Upgraded to plotly.js v1.42.5.
* Upgraded to plotly.js v1.45.3.
* Several new features and improvements related to accessing plotly.js events in shiny (learn more about them in this RStudio [webinar](https://resources.rstudio.com/webinars/accessing-and-responding-to-plotly-events-in-shiny-carson-sievert)):
* 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`.
Expand All @@ -19,10 +19,12 @@
* The `style()` function now supports "partial updates" (i.e. modification of a particular property of an object, rather than the entire object). For example, notice how the first plot retains the original marker shape (a square): `p <- plot_ly(x = 1:10, y = 1:10, symbol = I(15)); subplot(style(p, marker.color = "red"), style(p, marker = list(color = "red")))` (#1342).
* The `method` argument of `plotlyProxyInvoke()` gains support for a `"reconfig"` method. This makes it possible to modify just the configuration of a plot in a **shiny** app. For an example use, see `plotly_example("shiny", "event_data_annotation")`.
* The `plotly_example()` function will now attempt to open the source file(s) used to run the example. Set `edit = FALSE` to prevent the source file(s) from opening.
* An informative warning is now thrown if invalid argument names are supplied to `config()`.

## CHANGES

* The 'collaborate' button no longer appears in the modebar, and as a result, the `config()` function no longer has a `collaborate` argument.
* Since plotly.js now defaults to *not* showing the "Edit in Chart Studio" button, the `cloud` argument in `config()` was removed. If you want to show this button, use the new plotly.js `showSendToCloud` config attribute instead (e.g. `config(plot_ly(), showSendToCloud = TRUE)`)

## BUG FIXES

Expand Down
8 changes: 5 additions & 3 deletions R/ggplotly.R
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,11 @@ gg2list <- function(p, width = NULL, height = NULL,
)
# main plot title
if (nchar(plot$labels$title %||% "") > 0) {
gglayout$title <- faced(plot$labels$title, theme$plot.title$face)
gglayout$titlefont <- text2font(theme$plot.title)
gglayout$margin$t <- gglayout$margin$t + gglayout$titlefont$size
gglayout$title <- list(
text = faced(plot$labels$title, theme$plot.title$face),
font = text2font(theme$plot.title)
)
gglayout$margin$t <- gglayout$margin$t + gglayout$title$font$size
}
# ensure there's enough space for the modebar (this is based on a height of 1em)
# https://github.com/plotly/plotly.js/blob/dd1547/src/components/modebar/index.js#L171
Expand Down
4 changes: 1 addition & 3 deletions R/layout.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ rangeslider <- function(p, start = NULL, end = NULL, ...) {
#' @param p a plotly object
#' @param ... these arguments are documented at
#' \url{https://github.com/plotly/plotly.js/blob/master/src/plot_api/plot_config.js}
#' @param cloud include the send data to cloud button?
#' @param locale locale to use. See [here](https://github.com/plotly/plotly.js/tree/master/dist#to-include-localization) for more info.
#' @param mathjax add [MathJax rendering support](https://github.com/plotly/plotly.js/tree/master/dist#to-support-mathjax).
#' If `"cdn"`, mathjax is loaded externally (meaning an internet connection is needed for
Expand Down Expand Up @@ -130,7 +129,7 @@ rangeslider <- function(p, start = NULL, end = NULL, ...) {
#' config(p, locale = "zh-CN")
#'

config <- function(p, ..., cloud = FALSE, locale = NULL, mathjax = NULL) {
config <- function(p, ..., locale = NULL, mathjax = NULL) {

if (!is.null(locale)) {
p$dependencies <- c(
Expand Down Expand Up @@ -158,7 +157,6 @@ config <- function(p, ..., cloud = FALSE, locale = NULL, mathjax = NULL) {
args <- list(...)
if ("collaborate" %in% names(args)) warning("The collaborate button is no longer supported")
p$x$config <- modify_list(p$x$config, args)
p$x$config$cloud <- cloud

p
}
4 changes: 1 addition & 3 deletions R/plotly.R
Original file line number Diff line number Diff line change
Expand Up @@ -441,12 +441,10 @@ typedArrayPolyfill <- function() {
)
}

# TODO: suggest a plotlyBundles package that has trace-level bundles
# and bundle size at print time.
plotlyMainBundle <- function() {
htmltools::htmlDependency(
name = "plotly-main",
version = "1.42.5",
version = "1.45.3",
package = "plotly",
src = dependency_dir("plotlyjs"),
script = "plotly-latest.min.js",
Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
9 changes: 9 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,11 @@ verify_attr_names <- function(p) {
c(names(Schema$layout$layoutAttributes), c("barmode", "bargap", "mapType")),
"layout"
)
attrs_name_check(
names(p$x$config),
names(Schema$config),
"config"
)
for (tr in seq_along(p$x$data)) {
thisTrace <- p$x$data[[tr]]
attrSpec <- Schema$traces[[thisTrace$type %||% "scatter"]]$attributes
Expand Down Expand Up @@ -517,6 +522,10 @@ verify_attr <- function(proposed, schema) {

attrs_name_check <- function(proposedAttrs, validAttrs, type = "scatter") {
illegalAttrs <- setdiff(proposedAttrs, validAttrs)
if ("titlefont" %in% illegalAttrs) {
warning("The titlefont attribute is now deprecated. Use title = list(font = ...) instead.", call. = FALSE)
illegalAttrs <- setdiff(illegalAttrs, "titlefont")
}
if (length(illegalAttrs)) {
warning("'", type, "' objects don't have these attributes: '",
paste(illegalAttrs, collapse = "', '"), "'\n",
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) 2018 Plotly, Inc
Copyright (c) 2019 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/fi.js

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

2 changes: 1 addition & 1 deletion inst/htmlwidgets/lib/plotlyjs/locales/pl.js

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

6 changes: 3 additions & 3 deletions inst/htmlwidgets/lib/plotlyjs/plotly-latest.min.js

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions inst/htmlwidgets/plotly.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,6 @@ HTMLWidgets.widget({
}
}

// remove "sendDataToCloud", unless user has specified they want it
x.config = x.config || {};
if (!x.config.cloud) {
x.config.modeBarButtonsToRemove = x.config.modeBarButtonsToRemove || [];
x.config.modeBarButtonsToRemove.push("sendDataToCloud");
}

// if no plot exists yet, create one with a particular configuration
if (!instance.plotly) {

Expand Down
2 changes: 0 additions & 2 deletions man/config.Rd

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

Loading