Error when providing axis tickformat, but dataset is empty
还没有人认领这个 Issue。
- 主要语言
- JavaScript
- 星标
- 18.3k
- 派生
- 2k
- 平均合并
- 2 天 12 小时
- 30 天内合并 PR
- 28
描述
I could not find this anywhere in reported/open/closed problems, so here goes.
I'm dynamically fetching my dataset for plotly - and sometimes there is no data - a normal condition for my app.
When providing a timestamp-like xaxis tickformat, an error will occur when the dataset is empty.
Plotly.newPlot(this.chartTarget.id, {
data: [
{ name: "Spot", type: "scatter", mode: 'lines', x: [], y: [], line: {color: 'black'} },
],
layout: {
title: "Blah",
hovermode: "closest",
hoverlabel: { bgcolor: "#FFF" },
legend: { orientation: 'h', y: -0.3 },
xaxis: { tickformat: "%H:%M", title: {text: "Time", automargin: true, standoff: 0}, zeroline: false },
yaxis: { title: "YAxis" }
},
config: { responsive: true }
});
When the dataset is empty alike above (and only when empty), a JS error will be thrown with a trace that looks like:
console.trace() WARN: encountered bad format: "%H:%M" plotly-finance.js:27425:18
warn plotly-finance.js:27425
warnBadFormat plotly-finance.js:25902
numberFormat plotly-finance.js:50110
numFormat plotly-finance.js:40235
formatLinear plotly-finance.js:40138
tickText plotly-finance.js:39918
setTickLabel plotly-finance.js:39477
calcTicks plotly-finance.js:39509
drawOne plotly-finance.js:40613
draw plotly-finance.js:40541
syncOrAsync plotly-finance.js:26272
draw plotly-finance.js:40534
drawAxes plotly-finance.js:31315
syncOrAsync plotly-finance.js:26272
_doPlot plotly-finance.js:31340
newPlot plotly-finance.js:31501
It seems like the format handler should be able to detect this situation and avoid the error when there's actually nothing to format in the first place.
Thanks for consideration and hopeful for a resolution within plotly itself for this potentially-expected condition.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
使用空的 x 和 y 数组以及 xaxis tickformat "%H:%M" 重现所提供的 Plotly.newPlot 调用。从 newPlot 调用和 plotly-finance.js 中与格式相关的堆栈条目入手,然后确认空数据集不再产生 bad-format 错误。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100