I am working with a histogram and need to display some custom data in the tooltip.
This is how it currently looks:
As you can see pointed by the red arrow, outside the tooltip, there is some text (“Simulation and Testing”) which I want to display inside the tooltip, not outside.
This is how I have defined the bar chart and the tooltip with the custom data:
The histogram:
fig = px.bar(pivot,
x=pivot.index,
y=pivot.columns,
labels={"Time order": "Phase / Month", "value": "FTE"},
barmode="stack")
fig.update_layout(showlegend=True,
legend_title_text="Roles",
plot_bgcolor = "rgba(0, 0, 0, 0)",
paper_bgcolor = "rgba(0, 0, 0, 0)",
xaxis = dict(
tickmode = 'array',
tickvals = tick_values,
ticktext = tick_text,
tickangle=0,
)
The tooltip:
customdata = list(df[['Role']].to_numpy())
fig.update_traces(
customdata=customdata,
hovertemplate="<br>".join(
[
"Phase / Month: %{x}",
"<br>",
"Role: %{customdata}",
"<br>",
"FTE: %{y:.3s}%"
]
)
)
Do you know how I could use the text pointed by the red arrow inside the tooltip?