Im trying the Echarts library for 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.
Thanx for your help
Im trying the Echarts library for 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.
Thanx for your help
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) `
With jQuery:
// resize all charts
$(window).on('resize', function(){
$("[_echarts_instance_]").each(function(){
window.echarts.getInstanceById($(this).attr('_echarts_instance_')).resize()
});
});