Persistent, stateful hover, click, and selection properties
See original GitHub issueIn Dash, the Graph
component stores the data from hover, click, and selection events as part of the component’s state and passes that to the user as hoverData
, clickData
, selectionData
.
In some cases, the user may want to initialize their app with a point already “clicked”, a region “preselected”, or a point “hovered”.
This is related to “Customized Click, Hover, and Selection Styles”. The viewer will know that the graph has been pre-selected, clicked, or hovered through whatever custom styles the developer added.
Ideally, this API would match the same event data. For example, when hovering over a point, the event data might be:
{
"points": [{"x": 1, "y"; 4}]
}
Ideally, the user would be able to pass that in as part of the figure to trigger those styles themselves. That’s how the Dash API currently works although styles are not applied:
Graph(
figure={...},
hoverData={"points": [{"x": 1, "y": 4}]}
)
cc @alexcjohnson @etpinard @monfera @jackparmer @charleyferrari
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:17 (16 by maintainers)
Top GitHub Comments
hoverids
will be the values in the trace’sids
array corresponding the selected points.Would it be too much to ask to swap
customdata
forids
. PR https://github.com/plotly/plotly.js/pull/1770 made theids
attribute available to all trace types.To clarify the a few about @chriddyp 's last https://github.com/plotly/plotly.js/issues/1848#issuecomment-337715716, the API will more like:
Now to do something like @chriddyp 's
would be a little trickier, but not impossible as
mode
is not arrayOk. One would have to setmode: 'markers+text'
at the trace’s root level withtextfont.color: 'rgba(0,0,0,0)'
and then e.g. setselected.textfont.color: 'blue'
. Hmm maybe we could do better?Ha I see. Sounds to me we might need (down the road) some sort of shared data structure across traces: