only draw graphs in angular when not collapsed, perf improvement
This commit is contained in:
parent
61bfe20b94
commit
3f767c0b84
|
@ -43,6 +43,13 @@ app.directive('dgraph', ['$', '$filter', function($, filter) {
|
||||||
|
|
||||||
elem.height(elem.width() / 2);
|
elem.height(elem.width() / 2);
|
||||||
|
|
||||||
|
graph.setData([dconf, uconf]);
|
||||||
|
graph.resize();
|
||||||
|
graph.setupGrid();
|
||||||
|
graph.draw();
|
||||||
|
};
|
||||||
|
|
||||||
|
function update() {
|
||||||
var cnt = ((new Date - start)/1000).toFixed(0);
|
var cnt = ((new Date - start)/1000).toFixed(0);
|
||||||
|
|
||||||
dconf.data.push([cnt, dspeed]);
|
dconf.data.push([cnt, dspeed]);
|
||||||
|
@ -51,10 +58,10 @@ app.directive('dgraph', ['$', '$filter', function($, filter) {
|
||||||
uconf.data.push([cnt, uspeed]);
|
uconf.data.push([cnt, uspeed]);
|
||||||
if (uconf.data.length > graphSize) uconf.data.shift();
|
if (uconf.data.length > graphSize) uconf.data.shift();
|
||||||
|
|
||||||
graph.setData([dconf, uconf]);
|
// if any parents is collapsable, then confirm if it isnt
|
||||||
graph.resize();
|
var collapsable = elem.parents('.collapse');
|
||||||
graph.setupGrid();
|
if (!collapsable.length || collapsable.hasClass('in'))
|
||||||
graph.draw();
|
draw();
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.$watch(attrs.dspeed, function(val) {
|
scope.$watch(attrs.dspeed, function(val) {
|
||||||
|
@ -65,7 +72,7 @@ app.directive('dgraph', ['$', '$filter', function($, filter) {
|
||||||
uspeed = val;
|
uspeed = val;
|
||||||
});
|
});
|
||||||
|
|
||||||
var interval = setInterval(draw, 1000);
|
var interval = setInterval(update, 1000);
|
||||||
|
|
||||||
elem.bind('$destroy', function() {
|
elem.bind('$destroy', function() {
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user