Skip to content

Commit b6a3d5c

Browse files
authored
Handle altair's ConcatChart class more gracefully (#125)
1 parent 651caaa commit b6a3d5c

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

shinywidgets/_shinywidgets.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import json
1414
import os
1515
import tempfile
16+
import warnings
1617
from typing import Any, Optional, Sequence, Tuple, Union, cast, overload
1718
from uuid import uuid4
1819
from weakref import WeakSet
@@ -334,11 +335,19 @@ def set_layout_defaults(widget: Widget) -> Tuple[Widget, bool]:
334335
# container since it'll be contained within the Layout() container, which has a
335336
# full-fledged sizing API.
336337
if pkg == "altair":
337-
from altair import JupyterChart
338+
import altair as alt
338339

339340
# Since as_widget() has already happened, we only need to handle JupyterChart
340-
if isinstance(widget, JupyterChart):
341-
widget.chart = widget.chart.properties(width="container", height="container") # type: ignore
341+
if isinstance(widget, alt.JupyterChart):
342+
if isinstance(widget.chart, alt.ConcatChart):
343+
# Throw warning to use ui.layout_column_wrap() instead
344+
warnings.warn(
345+
"Consider using shiny.ui.layout_column_wrap() instead of alt.concat() "
346+
"for multi-column layout (the latter doesn't support filling layout)."
347+
)
348+
else:
349+
widget.chart = widget.chart.properties(width="container", height="container") # type: ignore
350+
342351

343352
return (widget, fill)
344353

0 commit comments

Comments
 (0)