Questions about Holoviews/Dash Integration

Hi all! This forum has been super helpful solving Dash and Plotly-related questions and with the new Holoviews integration I have a couple I’d like to figure out myself:

  • Is it possible to use Dash callbacks with Holoviews?

Say I’d like to link a map and histogram plot as in the NYC taxi demo, but I’d like to change the feature plotted on the histogram or even change the histogram to a scatter plot, etc., is this even possible? I tried a couple approaches and couldn’t get it to work and was thinking this might not be possible right now. Basically I’d like to be able to have “linked_selections” but have the graphs dynamically change based on other user inputs.

  • Is it possible to use Holoviews in Dash directly and use callbacks to grab selectedData information?

My use case is I have a map with scatter points and I’d like to update other plots based on the map selections. Holoviews/Geoviews has some really nice mapping utilities but I’m not sure if the connection to Dash is there. Even if I can’t do what I’m suggesting in the first question, it would be great to at least leverage those maps.

Hi @pavtloska,

Here are a few answers that I hope make some things a little more clear.

Is it possible to use Dash callbacks with Holoviews?

It’s possible to build Dash callbacks that are attached to the component created by to_holoviews. Here’s a sketch of what it would be like to attach a callback to the relayoutData prop of a Graph component created by the to_dash function.

components = to_dash(app, ...)
graph = components.graphs[0]

@app.callback(Output(...), [Input(graph.id, "relayoutData")])
def callback(relayout_data):
    ...

Basically I’d like to be able to have “linked_selections” but have the graphs dynamically change based on other user inputs.

This won’t really work right now since you’ll need to preconstruct all of the HoloViews elements that should be linked together before calling to_dash. Performance would suffer, but one option might be to create the all the plots up front, and then dynamically show and hide the Graph components to only display a few at a time.

Is it possible to use Holoviews in Dash directly and use callbacks to grab selectedData information?

As I noted above, you can get access to the Dash props of a Graph created by to_dash, but you can’t currently get access to the full, combined, selection expression that Dash HoloViews is computing internally to perform filtering. This is something I really want to figure out how to do (https://github.com/holoviz/holoviews/issues/4748), but it’s not possible yet.

Hope that at least helps clear a few things up!
-Jon

2 Likes

Hi @jmmease! My apologies for not getting back to you sooner! Also thank you very much for the presentation a few weeks ago, that was really informative!

I actually ended up building my own cross-filtering logic to capture and handle filtering across Plotly graphics and that seems to be working pretty well for now. So right now I’m able to fully customize plots on the fly and change the data plotted while filtering what is selected across all of them.

Definitely will be looking forward to getting access to Holoviews selections though because Geoviews would be really great to use as well.

Thanks!

@jmmease, Thanks for the reply. i’d like to know if there is any update on using holoviews link selection in dash callback? i use callback to return holoview graph to dash, the graph is ok, but link selection does not work. is there any way to work around of this?