ブラウザの幅を変更したときの話だけです
元.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
}
つけるだけやんけ、、