不使用渲染迷你图挂起浏览器的解决方案是将其称为异步(将偏移时间设置为队列)。见样本:
var sparklinesGantt = new Array();
var sprklGanttCounter = 0;
var sprklBlockQuickShow = 20; // sync elements count
var sprklBlockSofort = 15; // async elemenbts count quick show
var sprklBlockGroesse = 2; // block size for async
var renderGanttSparkline = function(obj) {
$(obj).css('padding-right','0px').sparkline('html', {
width: '100px',
height: '16px',
type: 'bullet',
targetWidth: 2,
performanceColor: '#d3d3d3',
targetColor: '#ffa500',
rangeColors: ['#d3d3d3', '#4169e1', '#d3d3d3']
});
};
var renderGanttSparklineAtom = function() {
var sprklCounterBlockNext = sprklGanttCounter + sprklBlockGroesse;
for (var c = sprklGanttCounter;sprklGanttCounter<sprklCounterBlockNext;c++) {
var obj = sparklinesGantt[sprklGanttCounter];
sprklGanttCounter++;
renderGanttSparkline(obj);
}
if (sprklGanttCounter < sparklinesGantt.length) {
setTimeout(renderGanttSparklineAtom, 1);
}
};
var ganttSparkline = function(id) {
var selector = ".gantt_sprkl";
if (id) {
selector = "#"+id;
}
if ($(selector).size() < sprklBlockQuickShow) {
renderGanttSparkline($(selector));
} else {
sparklinesGantt = jQuery.makeArray($(selector));
sprklGanttCounter = 0;
while (sprklGanttCounter<sprklBlockSofort) {
var obj = sparklinesGantt[sprklGanttCounter];
sprklGanttCounter++;
renderGanttSparkline(obj);
}
setTimeout(renderGanttSparklineAtom, 1);
}
};
$(document).ready(function() {
ganttSparkline();
});
再见
这是测试页面