Skip to content

Commit afcd08c

Browse files
koaningclaude
andauthored
Default forecast_chart width to "container" for responsive sizing (#189)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5096fbb commit afcd08c

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

demos/forecast_chart.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def _(np, pl):
8686

8787
@app.cell
8888
def _(AltairWidget):
89-
widget = AltairWidget(width=600, height=400)
89+
widget = AltairWidget(height=400)
9090
return (widget,)
9191

9292

@@ -115,7 +115,6 @@ def _(df, fit_window, forecast_chart, projection_days, widget):
115115
fit_window=fit_window.value,
116116
projection_days=projection_days.value,
117117
title="Synthetic metric forecast",
118-
width=600,
119118
)
120119
return (time,)
121120

@@ -152,7 +151,6 @@ def _(df, fit_window, forecast_chart, projection_days, time):
152151
fit_window=fit_window.value,
153152
projection_days=projection_days.value,
154153
title="Synthetic metric forecast (plain)",
155-
width=600,
156154
)
157155
return
158156

wigglystuff/utils.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def forecast_chart(
108108
fit_window: int = 180,
109109
projection_days: int = 365,
110110
title: str | None = None,
111-
width: int | None = None,
111+
width: int | str | None = None,
112112
height: int = 400,
113113
):
114114
"""Create a time series chart with an exponential forecast.
@@ -123,7 +123,7 @@ def forecast_chart(
123123
fit_window: Number of most-recent data points to use for the fit.
124124
projection_days: How many days to project into the future.
125125
title: Optional chart title.
126-
width: Chart width in pixels. If None, uses Altair default.
126+
width: Chart width in pixels, or "container" for responsive. Defaults to "container".
127127
height: Chart height in pixels (default 400).
128128
129129
Returns:
@@ -229,10 +229,9 @@ def forecast_chart(
229229

230230
props = {
231231
"height": height,
232+
"width": width if width is not None else "container",
232233
"usermeta": {"embedOptions": {"actions": False}},
233234
}
234-
if width is not None:
235-
props["width"] = width
236235
if title:
237236
props["title"] = title
238237

0 commit comments

Comments
 (0)