From 3c5854104e1de6033d453d6eee6917963234af49 Mon Sep 17 00:00:00 2001 From: Carson Date: Sat, 4 Sep 2021 12:02:34 -0500 Subject: [PATCH 1/2] Use Plotly.react() to redraw in Shiny if layout.transition is populated --- inst/htmlwidgets/plotly.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/inst/htmlwidgets/plotly.js b/inst/htmlwidgets/plotly.js index 97980a7e64..aaca427af0 100644 --- a/inst/htmlwidgets/plotly.js +++ b/inst/htmlwidgets/plotly.js @@ -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 From d39e06c717aa140d3136129c8aaed078f393c064 Mon Sep 17 00:00:00 2001 From: Carson Date: Mon, 20 Sep 2021 17:20:05 -0500 Subject: [PATCH 2/2] update news --- NEWS.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index c51491bc6e..e21f065d24 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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