We found an issue with Shiny rendering Altair charts where the size properties are not respected. These attributes work as expected when used in a Jupyter notebook but not within Shiny.
The Plotly equivalent attribute to set chart size works in Shiny without issue. There are also size attributes on the shinywidgets.output_widget method, which appear to work to increase the width but not height.
Minimal Example
import altair as alt
import shinywidgets
from shiny import ui, App
from vega_datasets import data
app_ui = ui.page_fluid(
shinywidgets.output_widget("render_graph"),
)
def server(input, output, session):
@shinywidgets.render_widget
def render_graph():
cars = data.cars()
chart = (
alt.Chart(cars)
.mark_point()
.encode(
x="Horsepower",
y="Miles_per_Gallon",
color="Origin",
)
.properties(width=500, height=2_000)
)
return chart
app = App(app_ui, server)
Issue
We found an issue with Shiny rendering Altair charts where the size properties are not respected. These attributes work as expected when used in a Jupyter notebook but not within Shiny.
The Plotly equivalent attribute to set chart size works in Shiny without issue. There are also size attributes on the
shinywidgets.output_widget
method, which appear to work to increase the width but not height.Minimal Example
Versions