How to display a busy indicator when querying data

I'm using the python version of shiny (for the first time) and I'm having trouble finding documentation/examples on the user of spinners / busy indicators. I'm using base rather than express. The documentation for ui.busy_indicators.use implies that the default is "enabled" but I cannot get it to work.

My ui code is

app_ui = ui.page_fixed(
    ui.layout_sidebar(
        ui.sidebar(
            ui.input_date_range("daterange", "Date range", start="2024-01-01"),
            ui.input_action_button("refresh", "Refresh"),
        ),
        ui.layout_columns(
            ui.card(
                ui.card_header("Plot"),
                output_widget("chart"),
            )
        ),
    ),
    ui.busy_indicators.use(spinners=True, pulse=True, fade=True),
)

And my server has a single function that renders an altair chart. It works but it takes a while to fetch and display the data and there's no feedback.

def server(input, output, session):
    @render_altair
    @reactive.event(input.refresh)
    def chart():
        df = data.read_data(start_date=input.daterange()[0], end_date=input.daterange()[1])
       ...
      return alt.Chart(df)...

I'd like some form of spinner to display while the server chart method is executing. How do I do this?

I found Executing on a different thread/process which seems to work. I'm not sure if there's an easier way but it solves my problem.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.