最近做項目發現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);
});
});
