最近做项目发现Highcharts无法自适应屏幕大小,看了API发现图表高度是固定的,于是只能调整图表的宽高度
$(function () {
$(window).resize(function () {
var windowHeight = 0;
var widowWidth = 0;
if (typeof (window.innerHeight) == 'number') {
windowHeight = window.innerHeight;
widowWidth = window.innerWidth;
}
else {
if (document.documentElement && document.documentElement.clientHeight) {
windowHeight = document.documentElement.clientHeight;
widowWidth = document.documentElement.clientWidth;
}
else {
if (document.body && document.body.clientHeight) {
windowHeight = document.body.clientHeight;
widowWidth = document.body.clientWidth;
}
}
}
var width_div = widowWidth / 2 - 20;
var height_div = windowHeight / 2 - 35;
$('#u99_img').css("height", height_div);
$('#u99_img').css("width", width_div);
$('#u100_img').css("height", height_div);
$('#u100_img').css("width", width_div);
});
});
