Register a client-side javascript callback when writing python script

I mainly use Plotly by python, and usually I create a dashboard with Streamlit or Panel. Forgive me for not using Dash! :rofl: So I’m not familiar with Dash.

Recently I want to create an interactive dashboard with a bar chart and a line chart. When I click or select one of the bar, the line chart should change correspondingly. So a callback is needed to get the bar info and redraw the line chart when one bar is clicked. Since I use Streamlit or Panel, I can’t make a python callback because in Streamlit or Panel the click event on bar, esp. the bar info is inaccessible (Maybe it’s because I haven’t found the way.)

Since Plotly is essentially a javascript library, I wonder whether there are some ways to register a client-side javascript callback when I write the python script, something like js_on_change or js_link in Bokeh. Writing some javescript code is fine for me. In this way, even with Streamlit or Panel, I can still achive the interactivity I want.

I have found the (click-events)[Click events in Python] tutorial, but that’s for jupyter notebook. I want to create a standalone HTML dashboard.

Thanks for any tips!

Hello @chenyulue and welcome to the forum!

Did you check the Clientside callbacks documentation? Clientside Callbacks | Dash for Python Documentation | Plotly

Thanks for your info! After I read the doc, if I understand it correctly, the clientside callbacks still need to work with Dash, because clientside_callback is a method of a Dash app.