Commit b28368c8 by Mitsuhiro Tanda

cache panel width

parent 2f5ae85d
...@@ -31,6 +31,7 @@ function (angular, $, moment, _, kbn, GraphTooltip) { ...@@ -31,6 +31,7 @@ function (angular, $, moment, _, kbn, GraphTooltip) {
var sortedSeries; var sortedSeries;
var legendSideLastValue = null; var legendSideLastValue = null;
var rootScope = scope.$root; var rootScope = scope.$root;
var panelWidth = 0;
rootScope.onAppEvent('setCrosshair', function(event, info) { rootScope.onAppEvent('setCrosshair', function(event, info) {
// do not need to to this if event is from this panel // do not need to to this if event is from this panel
...@@ -104,7 +105,7 @@ function (angular, $, moment, _, kbn, GraphTooltip) { ...@@ -104,7 +105,7 @@ function (angular, $, moment, _, kbn, GraphTooltip) {
return true; return true;
} }
if (elem.width() === 0) { if (panelWidth === 0) {
return true; return true;
} }
} }
...@@ -159,6 +160,16 @@ function (angular, $, moment, _, kbn, GraphTooltip) { ...@@ -159,6 +160,16 @@ function (angular, $, moment, _, kbn, GraphTooltip) {
// Function for rendering panel // Function for rendering panel
function render_panel() { function render_panel() {
if (!rootScope.panelWidthCache) {
rootScope.panelWidthCache = {};
}
if (rootScope.panelWidthCache[panel.span]) {
panelWidth = rootScope.panelWidthCache[panel.span];
} else {
panelWidth = elem.width();
rootScope.panelWidthCache[panel.span] = panelWidth;
}
if (shouldAbortRender()) { if (shouldAbortRender()) {
return; return;
} }
...@@ -276,7 +287,7 @@ function (angular, $, moment, _, kbn, GraphTooltip) { ...@@ -276,7 +287,7 @@ function (angular, $, moment, _, kbn, GraphTooltip) {
} }
function addTimeAxis(options) { function addTimeAxis(options) {
var ticks = elem.width() / 100; var ticks = panelWidth / 100;
var min = _.isUndefined(ctrl.range.from) ? null : ctrl.range.from.valueOf(); var min = _.isUndefined(ctrl.range.from) ? null : ctrl.range.from.valueOf();
var max = _.isUndefined(ctrl.range.to) ? null : ctrl.range.to.valueOf(); var max = _.isUndefined(ctrl.range.to) ? null : ctrl.range.to.valueOf();
...@@ -444,7 +455,7 @@ function (angular, $, moment, _, kbn, GraphTooltip) { ...@@ -444,7 +455,7 @@ function (angular, $, moment, _, kbn, GraphTooltip) {
} }
function render_panel_as_graphite_png(url) { function render_panel_as_graphite_png(url) {
url += '&width=' + elem.width(); url += '&width=' + panelWidth;
url += '&height=' + elem.css('height').replace('px', ''); url += '&height=' + elem.css('height').replace('px', '');
url += '&bgcolor=1f1f1f'; // @grayDarker & @grafanaPanelBackground url += '&bgcolor=1f1f1f'; // @grayDarker & @grafanaPanelBackground
url += '&fgcolor=BBBFC2'; // @textColor & @grayLighter url += '&fgcolor=BBBFC2'; // @textColor & @grayLighter
......
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