Solve the problem of echarts chart scaling beyond the parent container

 

The echarts chart will rush out of the parent container as the web page scales. The solution is as follows:

mounted(){
                setTimeout(() => {// 解决echarts图表放大溢出父容器
                    const resizeOb = new ResizeObserver((entries) => {
                        for (const entry of entries) {
                            echarts.getInstanceByDom(entry.target).resize();
                        }
                    });
                    resizeOb.observe(document.getElementById('average-chart'));
                });
}

Realization effect:

 

Guess you like

Origin blog.csdn.net/qq_54089372/article/details/126504217