plotly / plotly/plotly.js

“Error parsing” in empty axis

オープン
#6,298 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug P3
主要言語
JavaScript
スター
18.3k
フォーク
2k
平均マージ
2日 12時間
マージ済み PR(30日)
28

説明

I have a probably not common issue, but also probably easy to fix. I have also posted it in the community, and I reproduce it here.

I have a plot (that I create with Python but I edit later on the html/js) that looks like this:
6707dfe749f7dff3cada935f8145053ab34b425a

When I open the html, there are errors on the console:

Error: Problem parsing d="MNaN,NaNHNaNMNaN,NaNHNaN"
Error: Problem parsing d="MNaN,NaNHNaNMNaN,NaNHNaN"

Although the graphs look fine, these errors are annoying (as there are many graphs like this on the page, and therefore many errors).
(I have tested many versions 2.XX and it always happen, including 2.14.0).
Also, what seems to be causing this is related to the black line of xaxis2 and yaxis2 (which is the top-right graph). This is how the layout looks like for this part:

xaxis2: {
  anchor: "y2",
  domain: [0.806, 1.0],
  mirror: true,
  ticks: "",
  linecolor: "black",
  showgrid: false,
  range: [0.0, 1.0],
  fixedrange: true,
  showticklabels: false,
},
yaxis2: {
  anchor: "x2",
  domain: [0.73, 1.0],
  mirror: true,
  ticks: "",
  linecolor: "black",
  showgrid: false,
  range: [0.0, 1.0],
  fixedrange: true,
  showticklabels: false,
},

If I comment out the linecolor: "black", the errors disappear.

I have created a (somewhat) minimal example here: https://codepen.io/filipesmg/pen/ZExmorL
However, the error is not showing directly in codepen (maybe because the error is inside plotly.js?) If that code is put inside <html>(...)</html>, it shows up. The linecolor lines are 640 and 652.

Investigating the plotly.min.js file while running the code, I noticed that the error comes from this part:

(Y.attr = function (e, r) {
if (arguments.length < 2) {
(...)
}
return this.each(K(e, r));
}),

which calls the function K(e,r) that has:

function(){this.setAttribute(e,r)}}

The problem is that in my example, at some point there seems to be no argument to the function (e,r), and r is undefined. There are many times where arguments.length = 1 or 2, but there are 2 times where it is undefined. In these cases, it doesn't enter the if (arguments.length < 2) and it goes to return this.each(K(e, r)); where it gives an error in the .setAttribute(e,r). Maybe a simple if ( ! r) { return; } would solve the issue, but I can't follow more the code to know if it'd affect other things.

I'm using 12.3.1, and I this error shows up in Safari 15.4 and in Chrome 104.0.5112.79, but not on Firefox 103.0.2.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

最小限の CodePen 例と生成された HTML から始め、640 行目と 652 行目の xaxis2/yaxis2 の linecolor 設定に注目します。示されている attr/setAttribute コードを通る plotly.min.js のパスを追跡し、undefined 引数の場合を 2 つ比較します。再現したプロットがコンソールのパースエラーなしに描画され、軸の線が維持されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript
領域
data-visualization
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。