[BUG]: `hoverlabel.align` is ignored in `hovermode: "x unified"`
維護者通常 1 天內回覆
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 78/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- javascript
研究方向
先重現所提供的 unified-hoverlabel 範例,接著檢查 src/components/legend/draw.js 第 587 行附近的位置,issue 回報這裡將對齊方式硬編碼為 'start'。完成標準是:對於統一的 x 和 y hover label,遵循 hoverlabel.align,同時維持現有行為不變。
由索引模型根據 Issue 內容生成。
描述
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).
- 主要語言
- JavaScript
- 星號
- 18.4k
- 分支
- 2k
- 平均合併
- 2 天 7 小時
- 30 天內合併 PR
- 18
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
plotly/plotly.js 的其他 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 86/100
維護者通常 1 天內回覆
-
chore P3 plotly-internal size: 3 task
難度 2/5 1-3 小時 新手友好度 77/100
plotly/plotly.js#8064 · 1 則留言 ·
維護者通常 1 天內回覆
-
chore P1 plotly-internal size: 1 task
難度 1/5 1 小時以內 新手友好度 82/100
維護者通常 1 天內回覆
-
chore P3 plotly-internal size: 1 task
難度 2/5 1-3 小時 新手友好度 65/100
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 65/100
plotly/plotly.js#7648 · 3 則留言 ·
維護者通常 1 天內回覆
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 68/100
FuRongJun-1999/dsh-memory#56 ·
維護者通常 1 天內回覆
-
Bug
難度 2/5 1-3 小時 新手友好度 76/100
pgadmin-org/pgadmin4#10503 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
521xueweihan/HelloGitHub#3856 ·
-
needs-ac
難度 2/5 1-3 小時 新手友好度 78/100
Ikalus1988/MisakaNet#2845 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
neondatabase/website#6038 ·
維護者通常 1 天內回覆