Description
layout.hoverlabel.align (and trace-level hoverlabel.align) has no effect when hovermode is 'x unified' or 'y unified'. Row text in the unified label is always left-aligned.
Reported on the forum: https://community.plotly.com/t/hoverlabel-align-right-is-not-honored-in-hovermode-x-unified/97717
Repro
import plotly.graph_objects as go
people = ["Person A", "Person B", "Person C"]
fig = go.Figure()
for name, values in {
"Series 1": [3944, 2810, 1675],
"Series 2": [-266, -1020, -85],
"Series 3": [-44, -310, -7],
"Series 4": [-43, -5, -390],
}.items():
fig.add_trace(go.Bar(x=people, y=values, name=name, hovertemplate="%{y:,.0f} €<extra></extra>"))
# --- secondary-axis line: delete this block to test without it ---
fig.add_trace(go.Scatter(
x=people, y=[0.91, 0.62, 0.785], name="Ratio",
mode="lines+markers", yaxis="y2", line=dict(color="black"),
hovertemplate="%{y:.1%}<extra></extra>",
))
fig.update_layout(yaxis2=dict(overlaying="y", side="right", tickformat=".0%"))
# --- end ---
fig.update_layout(
barmode="relative",
separators=". ",
hovermode="x unified",
hoverlabel=dict(align="right"),
# Same with
# hoverlabel_align="right",
)
fig.show()
Expected: values right-aligned within the unified label.
Actual: left-aligned.
Screenshots/Video
Steps to reproduce
Reports must include steps to reproduce the issue. Alternatively, you can use codepen, jsfiddle or jsbin to share your example. Please use the latest (un-minified) version of plotly.js in your report unless not applicable.
- Go to '...'
- Click on X
- Note the issue with Y
Notes
This does appear to be a bug in plotly.js. The label is hardcoded to use 'start'.
It seems to lead to a 9 year old code (standardize on attr over style for text-anchor · plotly/plotly.js@3ad11f6 · GitHub).
Description
layout.hoverlabel.align(and trace-levelhoverlabel.align) has no effect whenhovermodeis'x unified'or'y unified'. Row text in the unified label is always left-aligned.Reported on the forum: https://community.plotly.com/t/hoverlabel-align-right-is-not-honored-in-hovermode-x-unified/97717
Repro
Expected: values right-aligned within the unified label.
Actual: left-aligned.
Screenshots/Video
Steps to reproduce
Reports must include steps to reproduce the issue. Alternatively, you can use codepen, jsfiddle or jsbin to share your example. Please use the latest (un-minified) version of plotly.js in your report unless not applicable.
Notes