plotly / plotly/plotly.js

[FEATURE]: minimum autorange window

Đang mở
#7,770 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

enhancement feature P3 size: 5
Ngôn ngữ chính
JavaScript
Star
18.3k
Fork
2k
Merge trung bình
2 ngày 12 giờ
Pull request đã merge (30 ngày)
28

Mô tả

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/clipmax cap 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:

  1. Compute normal autorange [amin, amax] from data (with existing padding rules).
  2. 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 include 22

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách lần theo cách xử lý yaxis.autorangeoptions hiện có, đặc biệt là clipmin, clipmax, minallowed và maxallowed, đồng thời xem xét cách Plotly.extendTraces và Plotly.relayout ảnh hưởng đến hành vi autorange khi streaming. Xác định API và xác minh rằng autorange giữ nguyên cửa sổ tối thiểu đã cấu hình khi dữ liệu vẫn nằm trong cửa sổ đó, đồng thời mở rộng đủ để bao gồm các giá trị ngoại lệ và các quy tắc padding hiện có.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript
Lĩnh vực
data-visualization
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
42/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.