javascript ECharts:如何使用窗口的resize事件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27800171/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 08:00:42 来源:igfitidea点击:
ECharts: How to use the resize event of the window?
提问by Lolo
Im trying the Echarts libraryfor my graphs. I'd like to resize the plots when the window's resize trigger is fired but I can't find the way to do it.
我正在 为我的图表尝试Echarts 库。当窗口的调整大小触发器被触发时,我想调整绘图的大小,但我找不到这样做的方法。
Thanx for your help
感谢您的帮助
回答by maralla
var plot = echarts.init(yourDom);
plot.setOption({...});
window.onresize = function() {
plot.resize();
};
回答by source box
window.onresize = function() {
$(".ga-charts").each(function(){
var id = $(this).attr('_echarts_instance_');
window.echarts.getInstanceById(id).resize();
});
};
回答by TristaLee
var allCharts = $('.charts');
setTimeout(function(){
for(var i=0;i<allCharts.length;i++){
var $item = $(allCharts[i]);
echarts.getInstanceById($item.attr('_echarts_instance_')).resize();
}
},100) `