Skip to content

Commit 0a909c8

Browse files
author
Jeffrey Shen
committed
Use react instead of newPlot as it is more efficient
1 parent 10f4dac commit 0a909c8

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

inst/htmlwidgets/plotly.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ HTMLWidgets.widget({
113113
flex.appendChild(container);
114114
}
115115
}
116-
116+
117117
// finally, insert the flexbox inside the htmlwidget container,
118118
// but before the plotly graph div
119119
graphDiv.parentElement.insertBefore(flex, graphDiv);
@@ -179,13 +179,7 @@ HTMLWidgets.widget({
179179
// this is essentially equivalent to Plotly.newPlot(), but avoids creating
180180
// a new webgl context
181181
// https://github.com/plotly/plotly.js/blob/2b24f9def901831e61282076cf3f835598d56f0e/src/plot_api/plot_api.js#L531-L532
182-
183-
// TODO: restore crosstalk selections?
184-
Plotly.purge(graphDiv);
185-
// TODO: why is this necessary to get crosstalk working?
186-
graphDiv.data = undefined;
187-
graphDiv.layout = undefined;
188-
var plot = Plotly.plot(graphDiv, x);
182+
var plot = Plotly.react(graphDiv, x);
189183
}
190184

191185
// Trigger plotly.js calls defined via `plotlyProxy()`

0 commit comments

Comments
 (0)