我正在为我的图表尝试Echarts 库 。我想在触发窗口的调整大小触发器时调整绘图的大小,但我找不到这样做的方法。
感谢您的帮助
var plot = echarts.init(yourDom);
plot.setOption({...});
window.onresize = function() {
plot.resize();
};
window.onresize = function() {
$(".ga-charts").each(function(){
var id = $(this).attr('_echarts_instance_');
window.echarts.getInstanceById(id).resize();
});
};
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) `
使用 jQuery:
// resize all charts
$(window).on('resize', function(){
$("[_echarts_instance_]").each(function(){
window.echarts.getInstanceById($(this).attr('_echarts_instance_')).resize()
});
});