plotly / plotly/plotly.js

Error when providing axis tickformat, but dataset is empty

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

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

bug P3
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ả

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.

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

Tái hiện lệnh gọi Plotly.newPlot được cung cấp với các mảng x và y rỗng cùng xaxis tickformat "%H:%M". Bắt đầu từ lệnh gọi newPlot và các mục stack liên quan đến định dạng trong plotly-finance.js, sau đó xác nhận rằng tập dữ liệu rỗng không còn tạo ra lỗi bad-format.

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
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/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.