0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

plotly.jsグラフサイズのリアルタイム変更について

0
Last updated at Posted at 2026-05-23

ブラウザの幅を変更したときの話だけです

元.html

<div id="chart" style="width:100%; height:100vh;"></div>

<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>

<script>
    Plotly.newPlot(
        'chart',
        [{
            x: ['A', 'B', 'C', 'D'],
            y: [10, 20, 30, 40],
            type: 'bar'
        }],
    );
</script>

widthChangeable.html

<div id="chart" style="width:100%; height:100vh;"></div>

<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>

<script>
    Plotly.newPlot(
        'chart',
        [{
            x: ['A', 'B', 'C', 'D'],
            y: [10, 20, 30, 40],
            type: 'bar'
        }],
        {
            autosize: true
        },
        {
            responsive: true
        }
    );
</script>

まとめ

{
    autosize: true
},
{
    responsive: true
}

つけるだけやんけ、、

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?