[FEATURE]: minimum autorange window
还没有人认领这个 Issue。
- 主要语言
- JavaScript
- 星标
- 18.3k
- 派生
- 2k
- 平均合并
- 2 天 12 小时
- 30 天内合并 PR
- 28
描述
Feature request: “minimum autorange window” (default range, expand only when data exceed bounds) for live graphs
Problem / Motivation
We are building a live (streaming) graph with Plotly.js. When using autorange: true, the y-axis can become too tightly zoomed around very small values. This makes it hard to follow the signal comfortably because the scale constantly re-adjusts to tiny changes.
At the same time, we need to see outliers immediately: if a value suddenly exceeds a threshold, the plot should expand so the outlier is visible and operators can react.
So we want a y-axis behavior like:
- Default to a “stable” range (e.g.
[-10, 10]) while data stay inside it (prevents over-zooming). - If any new data point goes below -10 or above 10, automatically expand the axis beyond that window (so outliers are visible).
- In other words: do not shrink inside the window, but do expand outside of it.
Why current options don’t solve it
layout.yaxis.autorangeoptions.clipmin/clipmaxcap the autorange result.
They prevent the axis from expanding beyond the clip values, which is the opposite of what we need (we want expansion beyond the threshold).autorangeoptions.minallowed/maxallowed(and axis-level allowed options) are hard limits / exact values and also do not provide “minimum window but expandable”.- The current workaround is to compute data min/max and call
Plotly.relayout()repeatedly, but this creates boilerplate, can fight user interactions, and is easy to get wrong for multi-axis / overlay cases.
Proposed feature
Add an autorange option that enforces a minimum visible window while still allowing expansion when data exceed the window.
Possible API (one of these, open to better naming):
yaxis.autorangeoptions.minwindow: [-10, 10]yaxis.autorangeoptions.minrange: 20(minimum span)- or similar
Proposed semantics
When autorange: true:
- Compute normal autorange
[amin, amax]from data (with existing padding rules). - Enforce: the final range must include the data, and must be at least the configured minimum window/span.
- If data are within the minimum window, use the minimum window exactly (stable view).
- If data exceed the window, expand as needed to include the data (outliers become visible).
Examples
Given minwindow: [-10, 10]:
- data in
[-3, 5]-> range should be[-10, 10] - data in
[-12, 5]-> range should expand to include-12(e.g.[-12, 10]plus padding if applicable) - data in
[-3, 22]-> range should expand to include22
Minimal reproduction / demonstration
Current behavior with autorange: true in a streaming graph:
- when values are close to 0, the axis zooms too tightly and keeps changing scale, making the chart hard to read.
Desired behavior:
- keep a stable default range (e.g.
[-10, 10]) until thresholds are exceeded, then expand.
(If maintainers want, I can provide a CodePen reproducing the streaming case using Plotly.extendTraces.)
Additional notes
This feature would be especially valuable for:
- live monitoring dashboards
- industrial / IoT telemetry
- finance signals with mostly small fluctuations but occasional spikes
It’s conceptually related to clipmin/clipmax, but with inverse behavior:
clip*= “don’t expand past these limits”minwindow= “don’t shrink inside these limits, but expand past them when necessary”- or you can add more values in autorangeoptions:
include
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先跟踪现有的 yaxis.autorangeoptions 处理逻辑,尤其是 clipmin、clipmax、minallowed 和 maxallowed,并检查 Plotly.extendTraces 和 Plotly.relayout 如何影响流式传输时的 autorange 行为。定义 API,并验证当数据保持在配置的最小窗口内时,autorange 会保留该最小窗口,同时充分扩展以包含异常值和现有的 padding 规则。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript
- 领域
- data-visualization
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100