Skip to content

Dash apps 🤝

This documentation page describes how you can integrate plotly-resampler in a dash application.

Examples of dash apps with plotly-resampler can be found in the examples folder of the GitHub repository.

Registering callbacks in a new dash app

When you add a FigureResampler figure in a basic dash app, you should:

Code illustration:

# Construct the to-be resampled figure
fig = FigureResampler(px.line(...))

# Construct app & its layout
app = dash.Dash(__name__)
app.layout = html.Div(children=[dcc.Graph(id="graph-id", figure=fig)])

# Register the callback
fig.register_update_graph_callback(app, "graph-id")

# start the app
app.run_server(debug=True)

Warning

The above example serves as an illustration, but uses a global variable to store the FigureResampler instance; this is not a good practice. Ideally you should cache the FigureResampler per session on the server side. In the examples folder, we provide several dash app examples where we perform server side caching of such figures.