@@ -31,6 +31,7 @@ function (angular, $, moment, _, kbn, GraphTooltip) {
31
31
var sortedSeries ;
32
32
var legendSideLastValue = null ;
33
33
var rootScope = scope . $root ;
34
+ var panelWidth = 0 ;
34
35
35
36
rootScope . onAppEvent ( 'setCrosshair' , function ( event , info ) {
36
37
// do not need to to this if event is from this panel
@@ -104,7 +105,7 @@ function (angular, $, moment, _, kbn, GraphTooltip) {
104
105
return true ;
105
106
}
106
107
107
- if ( elem . width ( ) === 0 ) {
108
+ if ( panelWidth === 0 ) {
108
109
return true ;
109
110
}
110
111
}
@@ -159,6 +160,16 @@ function (angular, $, moment, _, kbn, GraphTooltip) {
159
160
160
161
// Function for rendering panel
161
162
function render_panel ( ) {
163
+ if ( ! rootScope . panelWidthCache ) {
164
+ rootScope . panelWidthCache = { } ;
165
+ }
166
+ if ( rootScope . panelWidthCache [ panel . span ] ) {
167
+ panelWidth = rootScope . panelWidthCache [ panel . span ] ;
168
+ } else {
169
+ panelWidth = elem . width ( ) ;
170
+ rootScope . panelWidthCache [ panel . span ] = panelWidth ;
171
+ }
172
+
162
173
if ( shouldAbortRender ( ) ) {
163
174
return ;
164
175
}
@@ -276,7 +287,7 @@ function (angular, $, moment, _, kbn, GraphTooltip) {
276
287
}
277
288
278
289
function addTimeAxis ( options ) {
279
- var ticks = elem . width ( ) / 100 ;
290
+ var ticks = panelWidth / 100 ;
280
291
var min = _ . isUndefined ( ctrl . range . from ) ? null : ctrl . range . from . valueOf ( ) ;
281
292
var max = _ . isUndefined ( ctrl . range . to ) ? null : ctrl . range . to . valueOf ( ) ;
282
293
@@ -444,7 +455,7 @@ function (angular, $, moment, _, kbn, GraphTooltip) {
444
455
}
445
456
446
457
function render_panel_as_graphite_png ( url ) {
447
- url += '&width=' + elem . width ( ) ;
458
+ url += '&width=' + panelWidth ;
448
459
url += '&height=' + elem . css ( 'height' ) . replace ( 'px' , '' ) ;
449
460
url += '&bgcolor=1f1f1f' ; // @grayDarker & @grafanaPanelBackground
450
461
url += '&fgcolor=BBBFC2' ; // @textColor & @grayLighter
0 commit comments