Black Lives Matter. Please consider donating to Black Girls Code today.

Hovertemplate in stacked area chart

I’m trying to build a stacked area chart, starting from the example provided here.

However, I can’t seem to get hovertemplate to work on the filled area: hovering on a point works fine, but hovering over the corresponding filled area doesn’t use the provided template.

Here the code I’m currently using:

import plotly.graph_objects as go

fig = go.Figure()
for i, y in enumerate([0, 1]):
    values=[i, 1 + i, 2 + i, 1 + i, i]
    fig.add_trace(go.Scatter(x=[0, 1, 2, 3, 4], y=values,
                             hoveron = 'points+fills', # select where hover is active
                             name=f"Trace {y}",
                             hovertemplate="<span>Value: %{y}</span>")
    title = "hover on <i>points</i> or <i>fill</i>",

Also, the hover frame does not follow the cursor.

Thanks for any hint

Hi, and welcome to the community forum!

Can you be a bit more specific about the hover behavior you are trying to achieve?

What text do you want the hover to display when the user is hovering on a filled area but not a point?

I would like to have the same information when hovering over the filled area as what is displayed when hovering over a point.