plotly / plotly/plotly.js

3D plot redraw() inside a listener cause a recursive loop

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

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

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

説明

I have the following code to be executed:

this.$.plot3d.on('plotly_click', function(d){
  self.data[1].x.push(parseFloat(d.points[0].x))
  self.data[1].y.push(parseFloat(d.points[0].y))
  self.data[1].z.push(parseFloat(d.points[0].z))
  redrawing = true
  Plotly.redraw(self.$.plot3d); 
})

It just adds a 3D point (x,y,z) to a trace and then it redraws the plot.
If I do like this, as far as I seen, the redraw method somewhere trigger again the plotly_click event and this cause a recursive loop.

I used an ugly workaround to fix this, which is the following:

this.$.plot3d.on('plotly_click', function(d){
  if(!redrawing){        
    self.data[1].x.push(parseFloat(d.points[0].x))
    self.data[1].y.push(parseFloat(d.points[0].y))
    self.data[1].z.push(parseFloat(d.points[0].z))
    redrawing = true
    Plotly.redraw(self.$.plot3d);
  } else {
    redrawing = false
  }
})

But it's not hte best way. Am I do correctly redrawing the graph in a listener? Is there any other way (maybe the right one) to redraw a graph after a point selection? Is this allowed?

Thank you

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

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

はじめの一歩

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

調査の方向性

ファイルやテストは指定されていません。まず、提供された plotly_click listener を 3D プロット上で Plotly.redraw とともに再現し、次にイベントと redraw のエントリポイントを追跡して、redraw がクリックイベントを再度発行するかどうかを判断します。完了条件は、文書化された、または修正された動作によって再帰ループが発生しなくなり、適切な回帰テストでカバーされていることです。

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

評価

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

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

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