仅在最小化-最大化屏幕时正确绘制图表大小

时间:2020-10-28 14:00:22

标签: javascript plotly plotly.js

我会尽力解释这一点。我已经将图表绘制成HTML格式,一切看起来都很好。我已经使用js正确设置了autosize: true的布局自动调整大小。但是,在页面加载时,图表仅占用<div>的一半。当我将屏幕最小化为移动视图然后再次最大化时,图表将正确显示,占据了div的整个宽度。我不知道为什么,显然我希望图表显示全宽。前后请参见以下内容:

刚加载页面时div的屏幕截图。

enter image description here

最小化然后最大化屏幕后-您可以看到它占据了所需的全宽度

enter image description here

当前配置:

var layout= {
            xaxis: {
                title: {
                    text: 'X Axis Title',
                },
                automargin: true
            },
            yaxis: {
                title: {
                    text: 'Y Axis Title',
                },
                automargin: true
            },
            autosize: true,
            paper_bgcolor: "#00000000",
            plot_bgcolor: "#00000000"
        }
        
        Plotly.newPlot('chart_div', data, layout, {responsive: true}); 

0 个答案:

没有答案