Commit 2e6c2347 by Torkel Ödegaard

Did some jquery flot performance tuning, added text size cache that reduced…

Did some jquery flot performance tuning, added text size cache that reduced render times by 25% (for single serie graphs)
parent a256d71e
...@@ -122,6 +122,7 @@ Licensed under the MIT license. ...@@ -122,6 +122,7 @@ Licensed under the MIT license.
// re-calculating them when the plot is re-rendered in a loop. // re-calculating them when the plot is re-rendered in a loop.
this._textCache = {}; this._textCache = {};
this._textSizeCache = window.flotTextSizeCache = window.flotTextSizeCache || {};
} }
// Resizes the canvas to the given dimensions. // Resizes the canvas to the given dimensions.
...@@ -368,12 +369,17 @@ Licensed under the MIT license. ...@@ -368,12 +369,17 @@ Licensed under the MIT license.
element.addClass(font); element.addClass(font);
} }
info = styleCache[text] = { info = styleCache[text] = { element: element, positions: [] };
width: element.outerWidth(true),
height: element.outerHeight(true), var size = null;// this._textSizeCache[text];
element: element, if (size) {
positions: [] info.width = size.width;
}; info.height = size.height;
} else {
info.width = element.outerWidth(true);
info.height = element.outerHeight(true);
this._textSizeCache[text] = { width: info.width, height: info.height };
}
element.detach(); element.detach();
} }
...@@ -1416,8 +1422,7 @@ Licensed under the MIT license. ...@@ -1416,8 +1422,7 @@ Licensed under the MIT license.
var info = surface.getTextInfo(layer, t.label, font, null, maxWidth); var info = surface.getTextInfo(layer, t.label, font, null, maxWidth);
/// Grafana fix, add +1 to label width labelWidth = Math.max(labelWidth, info.width);
labelWidth = Math.max(labelWidth, info.width + 1);
labelHeight = Math.max(labelHeight, info.height); labelHeight = Math.max(labelHeight, info.height);
} }
...@@ -1729,8 +1734,6 @@ Licensed under the MIT license. ...@@ -1729,8 +1734,6 @@ Licensed under the MIT license.
axis.delta = delta; axis.delta = delta;
axis.tickDecimals = Math.max(0, maxDec != null ? maxDec : dec); axis.tickDecimals = Math.max(0, maxDec != null ? maxDec : dec);
axis.tickSize = opts.tickSize || size; axis.tickSize = opts.tickSize || size;
// grafana addition
axis.scaledDecimals = axis.tickDecimals - Math.floor(Math.log(axis.tickSize) / Math.LN10);
// Time mode was moved to a plug-in in 0.8, and since so many people use it // Time mode was moved to a plug-in in 0.8, and since so many people use it
// we'll add an especially friendly reminder to make sure they included it. // we'll add an especially friendly reminder to make sure they included it.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment