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

Use Plotly.react() to redraw in Shiny if layout.transition is populated #2001

Merged
merged 2 commits into from
Sep 20, 2021
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# 4.9.4.9000

## Changes to plotly.js
## Breaking changes in JavaScript API

* This version of the R package upgrades the version of the underlying plotly.js library from v1.57.1 to v2.2.1. 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
## Breaking changes in R API

* `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)

## New Features

Expand Down
4 changes: 4 additions & 0 deletions inst/htmlwidgets/plotly.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ HTMLWidgets.widget({
var plot = Plotly.newPlot(graphDiv, x);
instance.plotly = true;

} else if (x.layout.transition) {

var plot = Plotly.react(graphDiv, x);

} else {

// this is essentially equivalent to Plotly.newPlot(), but avoids creating
Expand Down