...
/Interactivity Attributes (hover, click, select, relayout)
Interactivity Attributes (hover, click, select, relayout)
Learn what interactivity attributes are available to trigger changes in Dash apps based on user interactivity, including hovers, clicks, and more.
Overview
Within the Dash ecosystem, we can take our Plotly graphs and, with the assistance of the dcc.Graph
component in particular, can change the nature of our plot in response to user interaction operations such as hovering, clicking, and selecting. In particular, we can use the hoverData
attribute within dcc.Graph
to capture information about exactly what the user is hovering over. With this and the combination of the figure
attribute, we can show the user exactly what they want to explore.
First, we will consider a simple example:
Hover using a simple example
Here we will investigate the previously seen built-in hover functionality within Plotly. Using Dash, we will display our figure, where all the plot hovering functionality has already been taken care of by Plotly. This is the beauty of Dash - it takes all that we have explored so far in Plotly and allows us to seamlessly integrate our plots of any kind into an interactive web app, all in Python!
In this example, we will plot sales against television advertising expenditure using the advertising dataset.
Hover interactivity and callbacks
Remember that we had many options when it came to hovering over data points. One such option was the ability to determine the hovermode
attribute within ...