Skip to content

Instantly share code, notes, and snippets.

@cpsievert
Last active September 17, 2024 22:18
Show Gist options
  • Save cpsievert/04e18b59ebc247551e47cc905f75ec1f to your computer and use it in GitHub Desktop.
Save cpsievert/04e18b59ebc247551e47cc905f75ec1f to your computer and use it in GitHub Desktop.
Minimal reprex for shinywidgets on shinyapps.io issue

This gist contains a minimal reprex for this CS ticket

The app.py was deployed here. If you visit there, and repeatedly refresh, you should (eventually) see this error:

Screenshot 2024-09-17 at 3 20 15 PM

Note that the reprex needs this branch of shinywidgets, which switches the order of the libembed-amd.js and output.js scripts in the head of the document.

For some reason, quarto serve seems to be ordering these <script> tags in this unexpected (at least compared to a normal shiny app) way.

import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
from shinywidgets import render_plotly, render_widget
from shiny import reactive, render, ui
from shiny.express import input, render, ui
data = px.data.gapminder().query("country == 'New Zealand'")
ui.input_select(
"value", "Value", choices=["lifeExp", "pop", "gdpPercap"], selected="pop"
)
@render_plotly
def display_trend():
value = input.value()
fig = px.bar(data, x="year", y=value, title=f"New Zealand {value} by year")
return fig
ipywidgets
pandas
plotly
shiny
shinywidgets @ git+https://github.com/posit-dev/py-shinywidgets.git@require-js-debug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment