Skip to content

Commit

Permalink
Use Plotly.react() to redraw in Shiny if layout.transition is populat…
Browse files Browse the repository at this point in the history
…ed (#2001)

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

* update news
  • Loading branch information
cpsievert authored Sep 20, 2021
1 parent a938bf5 commit 5b83c64
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
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

0 comments on commit 5b83c64

Please sign in to comment.