3
使用Raphael库饼图和hover属性会发生严重内存泄漏。如果我删除包含悬停属性的代码,它的效果很好,当我将它添加回内存占用区域时,它会稳定增长,并且悬停在饼图上会更加增加内存占用量。与大多数其他示例不同,我使用window.setInterval来不断更新页面(如果这有帮助的话)。 我不知道如何解决这个问题,并寻求帮助。使用raphael.js进行内存泄漏
以下是我正在做的事情的基础知识......几乎在Raphael网站上使用动态pieChart并添加了间隔计时器。我不知道如何利用没有内存问题的悬停效果???:
window.onload = setInterval(drawThePie, 10000);
function drawThePie() {
var mainCont = parent.frames["main"].document;
mainCont.getElementById("holder").innerHTML = "Getting data..";
//..Setting values for pieChart and legend into arrays here
//..Looping through color array and setting values for colorlist below
var r = Raphael("holder");
var aCircle = r.aCircle(85,85,78).attr({fill: "black"});
pie = r.piechart(85,85,75,data, {"legend": legend, "legendpos": "east", colors: colorlist });
if(dataNotZero > 0) { mainCont.getElementById("holder").innerHTML = "";}
pie.hover(function() {
this.sector.stop();
this.sector.scale(1.1, 1.1, this.cx, this.cy);
if (this.label) {
this.label[0].stop();
this.label[0].attr({ r: 7.5 });
this.label[1].attr({ "font-weight": 800 });
}
}, function() {
this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
if (this.label) {
this.label[0].animate({ r: 5 }, 500, "bounce");
this.label[1].attr({ "font-weight": 400 });
}
});
};