[BUG]: I cannot have reliable way of positioning title and legend on top without overlapping each other
还没有人认领这个 Issue。
- 主要语言
- JavaScript
- 星标
- 18.3k
- 派生
- 2k
- 平均合并
- 2 天 12 小时
- 30 天内合并 PR
- 28
描述
Description
As plotly is responsive there's currently no way to place both legend and title on the top of the chart so that title and legend do not overlap (seems legend doesn't take into account title/subtitle). I know I have some tools which can help (like setting top margin/playing with y/maxheight/yref) but all of them aren't reliable as resizing the window (thus resizing the chart)/having long trace names/etc breaks all hardcoded configurations.
Steps to reproduce
Here's the demo: https://python-fiddle.com/examples/plotly?checkpoint=1757947390
Code behind it:
import plotly.express as px
df = px.data.gapminder().query("year==2007")
fig = px.scatter(df, x="gdpPercap", y="lifeExp", color="continent",
size="pop", size_max=45, log_x=True)
fig.update_layout(legend=dict(
orientation="h",
entrywidth=70,
yanchor="bottom",
y=1.02,
xanchor="center",
x=1
))
fig.update_layout(title="Very long loong long long long title")
fig.show()
Notes
I'm posting python code here intentionally as I think this is the basic issue of the plotly.js rather than lack of configuration/bugs in Python wrapper.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从链接的 Python-Fiddle 复现开始,跟踪 plotly.js 在长标题和水平图例下的 responsive 布局行为。通过调整图表大小并改变 trace-name 的长度来确认结果;完成的标准是标题和图例在没有硬编码间距的情况下保持不重叠,并且有一项回归检查覆盖该复现。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100