We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c2b6d35 commit 2ae8e4bCopy full SHA for 2ae8e4b
shinywidgets/_shinywidgets.py
@@ -258,6 +258,22 @@ def _as_widget(x: object) -> Widget:
258
)
259
except Exception as e:
260
raise RuntimeError(f"Failed to coerce {x} into a BokehModel: {e}")
261
+ elif pkg == "plotly" and not isinstance(x, Widget):
262
+ try:
263
+ from plotly.graph_objects import Figure, FigureWidget
264
+
265
+ if isinstance(x, FigureWidget):
266
+ pass
267
+ elif isinstance(x, Figure):
268
+ x = FigureWidget(x.data, x.layout)
269
+ else:
270
+ raise TypeError(
271
+ f"{x} is not a plotly.graph_objects.Figure or FigureWidget"
272
+ )
273
+ except Exception as e:
274
+ raise RuntimeError(
275
+ f"Failed to coerce {x} into a plotly.graph_objects.FigureWidget: {e}"
276
277
278
if isinstance(x, Widget):
279
return x
0 commit comments