plotly / plotly/plotly.js

Plotly.react resets context and breaks autosize

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

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

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

説明

When calling Plotly.react to update the chart it decides to completely reset the context if the config parameter is present (https://github.com/plotly/plotly.js/blob/master/src/plot_api/plot_api.js#L2698-L2706).

This breaks the autosize feature since the _hasZeroHeight state was moved to the context (in https://github.com/plotly/plotly.js/pull/3090/files#diff-2941ab69a12080c0633ff4ac8ea3aa83R493-R494).

The context._hasZeroHeight is always reset to undefined, but in the second render the gd.clientHeight is no longer zero. So the height of the svg-container div will set to 100%, causing all the plot container to have no height.

Then in the third render gd.clientHeight will be zero again, so the svg-container div gets its height properly defined.

And so on...

An workaround is to call Plotly.react without the config (if nothing in it changed), but when using react-plotly.js that isn't an option, as it always call Plotly.react using the full signature (https://github.com/plotly/react-plotly.js/blob/master/src/factory.js#L80-L85).

See https://codepen.io/nantunes/pen/abvXgbd to reproduce. Click the "Change data" button to toggle the data and call Plotly.react. Notice that the red container div shrinks (or expands) its height.

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

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

はじめの一歩

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

調査の方向性

src/plot_api/plot_api.js の2698~2706行付近から始め、リンク先の CodePen で「Change data.」をクリックして動作を再現します。config が存在する場合に Plotly.react がコンテキストをリセットする仕組みを追跡します。autosize が振動せず、プロットコンテナの高さがなくなることもなくなり、react-plotly.js が使用する完全なシグネチャの呼び出しも含まれていれば完了です。

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

評価

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

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

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