Add css for loading visual hint to plotly figure div
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 18.8k
- フォーク
- 2.8k
- 平均マージ
- 16時間 26分
- マージ済み PR(30日)
- 21
説明
On a slow Internet connection, when loading a webpage with a plotly figure getting plotly from the cdn (created with include_plotlyjs=False), there is no visual indication that the figure is loading, the page is just empty and frozen until the figure is rendered. An alternative would be to add a loading div which would contain a rotating circle when the plotly fig div is rotating.
Here is an example of code (courtesy of @GaelVaroquaux)
Current plotly figure
<html>
<head><meta charset="utf-8" /></head>
<body>
<div>
<script type="text/javascript">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<div id="5ce67915-186c-4a00-9800-072154c9af49" class="plotly-graph-div" style="height:100%; width:100%;"></div>
<script type="text/javascript">
window.PLOTLYENV=window.PLOTLYENV || {};
if (document.getElementById("5ce67915-186c-4a00-9800-072154c9af49")) {
Plotly.newPlot(
'5ce67915-186c-4a00-9800-072154c9af49',
[{"type": "scatter", "x": [1, 2], "y": [2, 2]}],
{"template": {}},
{"responsive": true}
)
};
</script>
</div>
</body>
</html>
and adding the loading component
<html>
<head><meta charset="utf-8" /></head>
<body>
<div>
<style>
div.plotly-graph-loading {text-align: center; display: none;}
@keyframes spinner-border {
to { transform: rotate(360deg); }
}
div.plotly-graph-div:empty + div.plotly-graph-loading {
margin: -50% auto 0 auto;
display: block;
width: 3rem;
height: 3rem;
vertical-align: text-bottom;
border: .4rem solid #222;
border-right-color: transparent;
border-radius: 50%;
animation: spinner-border 1s linear infinite;
}
</style>
<div id="5ce67915-186c-4a00-9800-072154c9af49" class="plotly-graph-div" style="height:100%; width:100%;"></div>
<div class="plotly-graph-loading" role="status"></div>
<script type="text/javascript">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<script type="text/javascript">
window.PLOTLYENV=window.PLOTLYENV || {};
if (document.getElementById("5ce67915-186c-4a00-9800-072154c9af49")) {
Plotly.newPlot(
'5ce67915-186c-4a00-9800-072154c9af49',
[{"type": "scatter", "x": [1, 2], "y": [2, 2]}],
{"template": {}},
{"responsive": true}
)
};
</script>
</div>
</body>
</html>
This is a small addition but it can be helpful to show that something will happen. What do you think @nicolaskruchten @jonmease? I'm happy to make a PR but wanted to discuss it with you first.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Plotly figure div とその周囲の HTML を生成するコードを特定し、issue に示されている loading component と比較してください。低速な CDN 読み込みで結果を検証してください。空の figure には loading indicator が表示され、Plotly が figure をレンダリングすると消えるはずです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- css, html, python
- 領域
- data-visualization, frontend
- issue の種類
- 機能追加
- 難易度
- 3/5
- 見積もり時間
- 半日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100