mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
fix(graph): remove panel width cache, causing issues, does not handle window resize and fullscreen to dashboard, #5297
This commit is contained in:
parent
9bcd5de8ff
commit
fa10fc994a
@ -19,7 +19,6 @@ function (angular, $, moment, _, kbn, GraphTooltip) {
|
|||||||
|
|
||||||
var module = angular.module('grafana.directives');
|
var module = angular.module('grafana.directives');
|
||||||
var labelWidthCache = {};
|
var labelWidthCache = {};
|
||||||
var panelWidthCache = {};
|
|
||||||
|
|
||||||
module.directive('grafanaGraph', function($rootScope, timeSrv) {
|
module.directive('grafanaGraph', function($rootScope, timeSrv) {
|
||||||
return {
|
return {
|
||||||
@ -102,11 +101,6 @@ function (angular, $, moment, _, kbn, GraphTooltip) {
|
|||||||
|
|
||||||
if (!setElementHeight()) { return true; }
|
if (!setElementHeight()) { return true; }
|
||||||
|
|
||||||
if(_.isString(data)) {
|
|
||||||
render_panel_as_graphite_png(data);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (panelWidth === 0) {
|
if (panelWidth === 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -172,10 +166,7 @@ function (angular, $, moment, _, kbn, GraphTooltip) {
|
|||||||
|
|
||||||
// Function for rendering panel
|
// Function for rendering panel
|
||||||
function render_panel() {
|
function render_panel() {
|
||||||
panelWidth = panelWidthCache[panel.span];
|
panelWidth = elem.width();
|
||||||
if (!panelWidth) {
|
|
||||||
panelWidth = panelWidthCache[panel.span] = elem.width();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shouldAbortRender()) {
|
if (shouldAbortRender()) {
|
||||||
return;
|
return;
|
||||||
@ -461,80 +452,6 @@ function (angular, $, moment, _, kbn, GraphTooltip) {
|
|||||||
return "%H:%M";
|
return "%H:%M";
|
||||||
}
|
}
|
||||||
|
|
||||||
function render_panel_as_graphite_png(url) {
|
|
||||||
url += '&width=' + panelWidth;
|
|
||||||
url += '&height=' + elem.css('height').replace('px', '');
|
|
||||||
url += '&bgcolor=1f1f1f'; // @grayDarker & @grafanaPanelBackground
|
|
||||||
url += '&fgcolor=BBBFC2'; // @textColor & @grayLighter
|
|
||||||
url += panel.stack ? '&areaMode=stacked' : '';
|
|
||||||
url += panel.fill !== 0 ? ('&areaAlpha=' + (panel.fill/10).toFixed(1)) : '';
|
|
||||||
url += panel.linewidth !== 0 ? '&lineWidth=' + panel.linewidth : '';
|
|
||||||
url += panel.legend.show ? '&hideLegend=false' : '&hideLegend=true';
|
|
||||||
|
|
||||||
if (panel.yaxes && panel.yaxes.length > 0) {
|
|
||||||
var showYaxis = false;
|
|
||||||
for(var i = 0; panel.yaxes.length > i; i++) {
|
|
||||||
if (panel.yaxes[i].show) {
|
|
||||||
url += (panel.yaxes[i].min !== null && panel.yaxes[i].min !== undefined) ? '&yMin=' + panel.yaxes[i].min : '';
|
|
||||||
url += (panel.yaxes[i].max !== null && panel.yaxes[i].max !== undefined) ? '&yMax=' + panel.yaxes[i].max : '';
|
|
||||||
showYaxis = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url += showYaxis ? '' : '&hideYAxis=true';
|
|
||||||
}
|
|
||||||
|
|
||||||
url += panel.xaxis.show ? '' : '&hideAxes=true';
|
|
||||||
|
|
||||||
switch(panel.yaxes[0].format) {
|
|
||||||
case 'bytes':
|
|
||||||
url += '&yUnitSystem=binary';
|
|
||||||
break;
|
|
||||||
case 'bits':
|
|
||||||
url += '&yUnitSystem=binary';
|
|
||||||
break;
|
|
||||||
case 'bps':
|
|
||||||
url += '&yUnitSystem=si';
|
|
||||||
break;
|
|
||||||
case 'pps':
|
|
||||||
url += '&yUnitSystem=si';
|
|
||||||
break;
|
|
||||||
case 'Bps':
|
|
||||||
url += '&yUnitSystem=si';
|
|
||||||
break;
|
|
||||||
case 'short':
|
|
||||||
url += '&yUnitSystem=si';
|
|
||||||
break;
|
|
||||||
case 'joule':
|
|
||||||
url += '&yUnitSystem=si';
|
|
||||||
break;
|
|
||||||
case 'watt':
|
|
||||||
url += '&yUnitSystem=si';
|
|
||||||
break;
|
|
||||||
case 'ev':
|
|
||||||
url += '&yUnitSystem=si';
|
|
||||||
break;
|
|
||||||
case 'none':
|
|
||||||
url += '&yUnitSystem=none';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(panel.nullPointMode) {
|
|
||||||
case 'connected':
|
|
||||||
url += '&lineMode=connected';
|
|
||||||
break;
|
|
||||||
case 'null':
|
|
||||||
break; // graphite default lineMode
|
|
||||||
case 'null as zero':
|
|
||||||
url += "&drawNullAsZero=true";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
url += panel.steppedLine ? '&lineMode=staircase' : '';
|
|
||||||
|
|
||||||
elem.html('<img src="' + url + '"></img>');
|
|
||||||
}
|
|
||||||
|
|
||||||
new GraphTooltip(elem, dashboard, scope, function() {
|
new GraphTooltip(elem, dashboard, scope, function() {
|
||||||
return sortedSeries;
|
return sortedSeries;
|
||||||
});
|
});
|
||||||
@ -550,5 +467,4 @@ function (angular, $, moment, _, kbn, GraphTooltip) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user