plotly / plotly/plotly.js

`autorange` throws when y range is small

未关闭
#6,249 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

bug P2
主要语言
JavaScript
星标
18.3k
派生
2k
平均合并
2 天 12 小时
30 天内合并 PR
28

描述

When max(y) - min(y) is a very small value, ie, Number.MIN_VALUE, plotly failed to draw the plot.

Codepen https://codepen.io/opportunityliu/pen/QWmwPEO

TESTER = document.getElementById('tester');

Plotly.react( TESTER, [{
    x: [1, 2, 3, 4, 5],
    y: [0,0,0,0,Number.MIN_VALUE] }]);

image

Got error:

plotly-2.12.1.js:141901 
        
       Uncaught TypeError: Cannot read properties of undefined (reading 'val')
    at getAutoRange (plotly-2.12.1.js:141901:26)
    at doAutoRange (plotly-2.12.1.js:142098:56)
    at exports.doAutoRangeAndConstraints (plotly-2.12.1.js:140196:13)
    at doAutoRangeAndConstraints (plotly-2.12.1.js:134769:21)
    at lib.syncOrAsync (plotly-2.12.1.js:129221:15)
    at positionAndAutorange (plotly-2.12.1.js:134759:20)
    at lib.syncOrAsync (plotly-2.12.1.js:129221:15)
    at Object._doPlot (plotly-2.12.1.js:134834:24)
    at Object.newPlot (plotly-2.12.1.js:135011:20)
    at Object.react (plotly-2.12.1.js:137070:28)

When the diff become slightly larger, ie, 1e-310, I got another error and an empty plot

Codepen https://codepen.io/opportunityliu/pen/wvmBZEy

TESTER = document.getElementById('tester');

Plotly.react( TESTER, [{
    x: [1, 2, 3, 4, 5],
    y: [0,0,0,0,1e-310] }]);

image

plotly-2.12.1.js:153093 
        
       Uncaught Error: Something went wrong with axis scaling
    at ax.setScale (plotly-2.12.1.js:153093:19)
    at axes.drawOne (plotly-2.12.1.js:144647:8)
    at plotly-2.12.1.js:144605:31
    at lib.syncOrAsync (plotly-2.12.1.js:129221:15)
    at axes.draw (plotly-2.12.1.js:144600:16)
    at drawAxes (plotly-2.12.1.js:134783:21)
    at lib.syncOrAsync (plotly-2.12.1.js:129221:15)
    at Object._doPlot (plotly-2.12.1.js:134834:24)
    at Object.newPlot (plotly-2.12.1.js:135011:20)
    at Object.react (plotly-2.12.1.js:137070:28)

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

使用两个 JavaScript 示例复现该失败,并跟踪从 getAutoRange 和 doAutoRange 到 ax.setScale 的报告堆栈。当两个非常小的 y 范围都能成功渲染,且不再出现未定义值或坐标轴缩放错误时,修复就完成了。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript
领域
data-visualization
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。