Flot: dramatic performance improvements
Redraws graphs in place instead of recomputing them from scratch on each new time index.
This commit is contained in:
parent
6a7711376b
commit
afa779685d
1 changed files with 21 additions and 2 deletions
|
@ -49,7 +49,8 @@
|
|||
|
||||
this.clockSub = clock.subscribe(function(t) {
|
||||
self.trimData(t);
|
||||
self.setupGraph(t);
|
||||
self.updateTime(t);
|
||||
// self.setupGraph(t);
|
||||
});
|
||||
|
||||
// Subscribe to our query
|
||||
|
@ -70,7 +71,10 @@
|
|||
FlotView.prototype.setupGraph = function(t) {
|
||||
if (this.container.width() === 0 ||
|
||||
this.container.height() === 0) {
|
||||
this.graph = null;
|
||||
if (this.graph != null) {
|
||||
this.graph.shutdown();
|
||||
this.graph = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -100,6 +104,21 @@
|
|||
});
|
||||
};
|
||||
|
||||
// Called as the clock advances to new times.
|
||||
FlotView.prototype.updateTime = function(t) {
|
||||
if (this.graph == null) {
|
||||
console.log("first initialization");
|
||||
this.setupGraph(t);
|
||||
return;
|
||||
}
|
||||
|
||||
var axis = this.graph.getOptions().xaxes[0];
|
||||
axis.min = t - this.timeRange;
|
||||
axis.max = t;
|
||||
this.graph.setupGrid();
|
||||
this.graph.draw();
|
||||
}
|
||||
|
||||
// Re-order the data list and series index to be in sorted order by label.
|
||||
FlotView.prototype.resortSeries = function() {
|
||||
// Shorten labels
|
||||
|
|
Loading…
Reference in a new issue