Get currentPath from sunburst in dash

I’m trying to build a dash app that will display data based on the currently selected wedge in a sunburst, but I’m having trouble getting that event. If I react to hoverData then the event fires incessantly and causes the graph to flicker annoyingly. If I don’t use that, I can’t get any of the other properties listed here to change on click.

I would love to know:

  1. is there something that updates when a user clicks on a wedge in the sunburst that I could use as an Input so that I could read the State("graph", "hoverData") -> ["currentPath"]?
  2. If I have to react to a change in hoverData and PreventUpdate if it hasn’t changed, is there a way for me to make it only fire once per second, say?

Oh wow it turns out even currentPath is only the hover’s current path. So even using hover, I’d need to also get the current center of the sunburst from the figure I guess

Hi @dash_question_j, welcome to the forum!

For your first question, we plan to add click events in a sunburst (and treemap) chart to the clickData so that you can use clickData in your callback as in the tutorial See the open issue, it should be implemented in one of the few next releases so please stay tuned.

For the second question, you could record the current time (time.time()) in a dcc.Store which would be used as State, and then raise PreventUpdate if the callback is fired again less than one second after the previous call?

Awesome! huh I searched the github and didn’t see that issue before, wonder how I missed it. Thanks, that will solve it perfectly!

I’ll try the time-based solution for now, I appreciate the quick response!

Hi @Emmanuelle,

On using click data, am not able to get the click events for the non-root or non-leaf part of the graph. Is there an alternative for this.

click events are now available for all sectors in plotly.js 1.52, which is shipped with Dash 1.8.0.

Is it possible to query the current path from browser-side javascript without firing an event?