posit-dev / py-shinywidgets

Render ipywidgets inside a PyShiny app
MIT License
41 stars 2 forks source link

altair chart height is incorrect on safari #144

Open cpsievert opened 3 months ago

cpsievert commented 3 months ago
import altair
import pandas as pd
import plotly.express
import shiny

import shinywidgets

_SOURCE_DATA = pd.DataFrame(
    {
        "a": ["A", "B", "C", "D", "E", "F", "G", "H", "I"],
        "b": [28, 55, 43, 91, 81, 53, 19, 87, 52],
    }
)

UI = shiny.ui.page_fixed(
    shinywidgets.output_widget("plot")
)

def server(input):

    @shinywidgets.render_widget
    def plot():
        return altair.Chart(_SOURCE_DATA).mark_bar().encode(x="a", y="b")

app = shiny.App(UI, server)
Screenshot 2024-03-19 at 2 02 41 PM
cpsievert commented 3 months ago

I can actually reproduce this behavior in a Jupyter notebook with .properies(height="container"), so I don't think it's on shinywidgets to fix it:

Screenshot 2024-03-19 at 4 41 15 PM

A workaround in the meantime is to set an explicit height on the chart (e.g., chart.properties(height=400))