Skip to content

[Bug]: Using "native" @shiny.express rendering for Plotly charts causes a chart to be not rendered on initial app load #2008

@pfalcon

Description

@pfalcon

Component

UI (ui.*)

Severity

P2 - Medium (workaround exists)

Shiny Version

1.4.0

Python Version

3.10.12

Minimal Reproducible Example

import plotly.express as px
from shiny.express import input, ui, render


ui.input_slider("n", "Number of sth", 1, 100, 20)

@render.express
def render_func():
    _ = input.n()
    ui.h1("Heading1")
    fig = px.line(x=[1, 2, 3], y=[4, 1, 2])
    fig

Behavior

Please see #2007 for the motivation to work out such issues.

What I see with the above code is that on initial load, "Heading1" is rendered, but the chart isn't. Dragging slider causes the chart to be rendered.

Note the code

import plotly.express as px
from shiny.express import input, ui


ui.input_slider("n", "Number of sth", 1, 100, 20)

fig = px.line(x=[1, 2, 3], y=[4, 1, 2])
fig

has the chart rendered on the initial load.

Mind that shinywidgets (or more specifically IPython) should not be install for anything of that to work at all: posit-dev/py-shinywidgets#201

Error Messages (if any)

Environment

Ubuntu Linux 22.04

Chromium 126


$ pip freeze
anyio==4.9.0
appdirs==1.4.4
asgiref==3.8.1
click==8.2.1
exceptiongroup==1.3.0
h11==0.16.0
htmltools==0.6.0
idna==3.10
linkify-it-py==2.0.3
markdown-it-py==3.0.0
mdit-py-plugins==0.4.2
mdurl==0.1.2
narwhals==1.41.1
numpy==2.2.6
orjson==3.10.18
packaging==25.0
pandas==2.3.0
plotly==6.1.2
prompt_toolkit==3.0.51
python-dateutil==2.9.0.post0
python-multipart==0.0.20
pytz==2025.2
questionary==2.1.0
shiny==1.4.0
six==1.17.0
sniffio==1.3.1
starlette==0.47.0
typing_extensions==4.14.0
tzdata==2025.2
uc-micro-py==1.0.3
uvicorn==0.34.3
watchfiles==1.0.5
wcwidth==0.2.13
websockets==15.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions