[BUG]: Range slider y-axis "fixed" rangemode renders unexpected thick horizontal bars on initial load
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 18.8k
- 派生
- 2.8k
- 平均合并
- 16 小时 26 分钟
- 30 天内合并 PR
- 21
描述
Description
When initializing a Plotly chart with an xaxis range slider that has its yaxis.rangemode set to "fixed", the chart initially renders two extra, thick, solid gray horizontal bars stretching across the entire width of the range slider track.
However, this appears to be a visual artifact or initialization bug: if you dynamically toggle the rangemode to "auto" or "match" (via an updatemenu dropdown) and then switch it back to "fixed", the gray bars disappear entirely, and the range slider track displays normally as expected.
Screenshots/Video
Initial render (Buggy):
After toggling to "Auto"/"Match" and back to "Fixed" (Expected):
Steps to reproduce
- Run the provided Python script to generate the Plotly figure.
- Observe the range slider at the bottom of the chart upon initial rendering. Note the unexpected thick gray horizontal bars spanning the slider track.
- Use the dropdown menu in the top-left corner to select "Rangemode: Auto/Match".
- Use the dropdown menu again to select "Rangemode: Fixed".
- Observe that the range slider now looks correct and the gray bars have vanished.
import plotly; print(plotly.__version__) # 6.8.0
import pandas as pd
pd.options.plotting.backend = "plotly"
df = pd.DataFrame(dict(a=[1, 3, 2], b=[3, 2, 1]))
fig = df.plot.line()
fig.update_layout(xaxis=dict(rangeslider=dict(visible=True, yaxis=dict(rangemode="fixed"))))
fig.update_layout(
updatemenus=[
dict(
type="dropdown",
active=1,
buttons=[
dict(
label="Rangemode: Auto",
method="relayout",
args=[{"xaxis.rangeslider.yaxis.rangemode": "auto"}],
),
dict(
label="Rangemode: Fixed",
method="relayout",
args=[{"xaxis.rangeslider.yaxis.rangemode": "fixed"}],
),
dict(
label="Rangemode: match",
method="relayout",
args=[{"xaxis.rangeslider.yaxis.rangemode": "match"}],
),
],
)
]
)
fig.show()
Notes
- Environment: Verified using
plotlyversion6.8.0alongsidepandasplotting backend. - This behavior suggests a missing or improper initialization redraw when
rangemode="fixed"is passed via the initial layout configuration, which is subsequently corrected wheneverrelayouttriggers a fresh calculation of the range slider boundaries.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先使用 Plotly 6.8.0 和 pandas 运行提供的 Python 复现,比较初始的 fixed rangemode 与后续的 relayout 行为。跟踪 range-slider 的初始化和 redraw 路径,以确定为什么灰色条只在初始渲染时出现。完成的标准是 fixed rangemode 初始渲染时不显示这些条,并且切换模式时行为仍然正确。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- pandas, python
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 56/100