本文介绍了Google图表重绘/缩放窗口大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何重新绘制/重新缩放窗口大小的谷歌折线图?

仅在完成窗口大小调整时重绘

并避免多重触发器,我认为最好创建一个事件:

//创建触发器来调整尺寸事件
$(window).resize(function(){
if(this.resizeTO)clearTimeout(this.resizeTO);
this.resizeTO = setTimeout(function(){
$(this).trigger('resizeEnd');
},500);
});

//在窗口调整大小完成时重绘图形
$(window).on('resizeEnd',function(){
drawChart(data);
} );


How do I redraw/rescale a google linechart on window resize?

解决方案

To redraw only when the window resize is completed and avoid multiple triggers, I think is better create an event:

//create trigger to resizeEnd event
$(window).resize(function() {
    if(this.resizeTO) clearTimeout(this.resizeTO);
    this.resizeTO = setTimeout(function() {
        $(this).trigger('resizeEnd');
    }, 500);
});

//redraw graph when window resize is completed
$(window).on('resizeEnd', function() {
    drawChart(data);
});

这篇关于Google图表重绘/缩放窗口大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 08:22