给图表设置一个事件,初始化后,把TABLE_THREEQY改成你的图表名(有两处地方,要大写)
setTimeout(function() {a();}, 1000);
function a(){
var $report = $("div[widgetname=TABLE_THREEQY]");
//获取对应report的div元素
var $scroll = $report.find("#frozen-center");
//获取对应report的div元素的滚动块元素,冻结为#frozen-center,未冻结且未安装自定义滚动条插件为.reportContent,未冻结且安装了自定义滚动条插件为.scrollDiv
var flag = window.flag19;
//设置全局变量flag,每个报表块需保证各不相同
$report.find("#frozen-center").css('overflow-x', 'hidden');
$report.find("#frozen-center").css('overflow-y', 'hidden');
$report.find("#frozen-north").css('overflow-x', 'hidden');
$report.find("#frozen-north").css('overflow-y', 'hidden');
//冻结情况下隐藏滚动条
$report.find(".reportContent").css('overflow-y', 'hidden');
$report.find(".reportContent").css('overflow-x', 'hidden');
//非冻结情况下隐藏滚动条
flag = true;
//定义全局参数flag,用来控制滚动的暂停和继续
$scroll.mouseover(function() {
flag = false;
})
//鼠标悬浮,滚动停止
$scroll.mouseleave(function() {
flag = true;
})
//鼠标离开,继续滚动
var old = -1;
setInterval(function() {
if (flag) {
currentpos = $scroll[0].scrollTop;
//获取距顶部距离
if (currentpos == old) {
$scroll[0].scrollTop = 0;
//若已到达底部,则重置
} else {
old = currentpos;
$scroll[0].scrollTop = currentpos + 1.0;
//若未到达底部,则向下移动1.5像素
}
}
}, 120);
//以25ms的频率执行
}
setTimeout(function(){
var Stopper='TABLE_THREEQY'
var targetNode = $('div[widgetname="'+Stopper+'"]')[0]//监听报表块的div元素
var options = { attributes:false,characterData: true, childList: true,subtree:true,attributeOldValue:false,characterDataOldValue:true};
function callback(mutationsList, observer) {
a();
}
var mutationObserver = new MutationObserver(callback);
mutationObserver.observe(targetNode, options)
},1000)