@@ -312,24 +312,27 @@ def set_layout_defaults(widget: Widget) -> Tuple[Widget, bool]:
312
312
313
313
layout = widget .layout # type: ignore
314
314
315
- # Give the ipywidget Layout() width/ height defaults that are more sensible for
316
- # filling layout https://ipywidgets.readthedocs.io/en/stable/examples/Widget%20Layout.html
315
+ # If the ipywidget Layout() height is set to something other than "auto", then
316
+ # don't do filling layout https://ipywidgets.readthedocs.io/en/stable/examples/Widget%20Layout.html
317
317
if isinstance (layout , Layout ):
318
- if layout .width is None : # type: ignore
319
- layout .width = "100%"
320
- if layout .height is None : # type: ignore
321
- layout .height = "400px"
322
- else :
323
- if layout .height != "auto" : # type: ignore
318
+ if layout .height is not None and layout .height != "auto" : # type: ignore
319
+ fill = False
320
+
321
+ pkg = widget_pkg (widget )
322
+
323
+ # Plotly provides it's own layout API (which isn't a subclass of ipywidgets.Layout)
324
+ if pkg == "plotly" :
325
+ from plotly .graph_objs import Layout as PlotlyLayout
326
+ if isinstance (layout , PlotlyLayout ):
327
+ if layout .height is not None :
324
328
fill = False
325
329
326
330
widget .layout = layout
327
331
328
- # Some packages (e.g., altair) aren't setup to fill their parent container by
329
- # default. I can't imagine a situation where you'd actually want it to _not_ fill
330
- # the parent container since it'll be contained within the Layout() container, which
331
- # has a full-fledged sizing API.
332
- pkg = widget_pkg (widget )
332
+ # altair, confusingly, isn't setup to fill it's Layout() container by default. I
333
+ # can't imagine a situation where you'd actually want it to _not_ fill the parent
334
+ # container since it'll be contained within the Layout() container, which has a
335
+ # full-fledged sizing API.
333
336
if pkg == "altair" :
334
337
from altair import JupyterChart
335
338
0 commit comments