diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f89aa88b9b..2d3c9387972 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,9 @@ - Search HTTP API response has changed (simplified), tags list moved to seperate HTTP resource URI - Datasource HTTP api breaking change, ADD datasource is now POST /api/datasources/, update is now PUT /api/datasources/:id +**Fixes** +- [Issue #2185](https://github.com/grafana/grafana/issues/2185). Graph: fixed PNG rendering of panels with legend table to the right + # 2.0.3 (unreleased - 2.0.x branch) **Fixes** diff --git a/pkg/components/renderer/renderer.go b/pkg/components/renderer/renderer.go index 9d5ddd00d73..ec11a9ac36f 100644 --- a/pkg/components/renderer/renderer.go +++ b/pkg/components/renderer/renderer.go @@ -54,7 +54,7 @@ func RenderToPng(params *RenderOpts) (string, error) { }() select { - case <-time.After(10 * time.Second): + case <-time.After(15 * time.Second): if err := cmd.Process.Kill(); err != nil { log.Error(4, "failed to kill: %v", err) } diff --git a/public/app/features/dashboard/dashboardCtrl.js b/public/app/features/dashboard/dashboardCtrl.js index ffead046211..f25fea26afe 100644 --- a/public/app/features/dashboard/dashboardCtrl.js +++ b/public/app/features/dashboard/dashboardCtrl.js @@ -84,6 +84,7 @@ function (angular, $, config) { }; $scope.broadcastRefresh = function() { + $rootScope.performance.panelsRendered = 0; $rootScope.$broadcast('refresh'); }; diff --git a/public/app/features/dashboard/dynamicDashboardSrv.js b/public/app/features/dashboard/dynamicDashboardSrv.js index 8e10619aec8..fe0ffe47e51 100644 --- a/public/app/features/dashboard/dynamicDashboardSrv.js +++ b/public/app/features/dashboard/dynamicDashboardSrv.js @@ -164,6 +164,7 @@ function (angular, _) { _.each(selected, function(option, index) { var copy = self.getPanelClone(panel, row, index); + copy.span = 12 / selected.length; copy.scopedVars = copy.scopedVars || {}; copy.scopedVars[variable.name] = option; }); diff --git a/public/app/features/panel/panelSrv.js b/public/app/features/panel/panelSrv.js index b863518ff72..037125b4aad 100644 --- a/public/app/features/panel/panelSrv.js +++ b/public/app/features/panel/panelSrv.js @@ -86,6 +86,10 @@ function (angular, _, config) { return datasourceSrv.get($scope.panel.datasource); }; + $scope.panelRenderingComplete = function() { + $rootScope.performance.panelsRendered++; + }; + $scope.get_data = function() { if ($scope.otherPanelInFullscreenMode()) { return; } diff --git a/public/app/panels/dashlist/module.js b/public/app/panels/dashlist/module.js index 9b4e1ebc045..647199d6538 100644 --- a/public/app/panels/dashlist/module.js +++ b/public/app/panels/dashlist/module.js @@ -66,6 +66,7 @@ function (angular, app, _, config, PanelMeta) { return backendSrv.search(params).then(function(result) { $scope.dashList = result; + $scope.panelRenderingComplete(); }); }; diff --git a/public/app/panels/graph/graph.js b/public/app/panels/graph/graph.js index c6ca8ec7227..0f6ae7baeeb 100755 --- a/public/app/panels/graph/graph.js +++ b/public/app/panels/graph/graph.js @@ -247,22 +247,26 @@ function (angular, $, kbn, moment, _, GraphTooltip) { sortedSeries = _.sortBy(data, function(series) { return series.zindex; }); - function callPlot() { + function callPlot(incrementRenderCounter) { try { $.plot(elem, sortedSeries, options); } catch (e) { console.log('flotcharts error', e); } + + if (incrementRenderCounter) { + scope.panelRenderingComplete(); + } } if (shouldDelayDraw(panel)) { // temp fix for legends on the side, need to render twice to get dimensions right - callPlot(); - setTimeout(callPlot, 50); + callPlot(false); + setTimeout(function() { callPlot(true); }, 50); legendSideLastValue = panel.legend.rightSide; } else { - callPlot(); + callPlot(true); } } diff --git a/public/app/panels/singlestat/singleStatPanel.js b/public/app/panels/singlestat/singleStatPanel.js index 27a0167f05b..4bb1fc658f0 100644 --- a/public/app/panels/singlestat/singleStatPanel.js +++ b/public/app/panels/singlestat/singleStatPanel.js @@ -20,6 +20,7 @@ function (angular, app, _, $) { scope.$on('render', function() { render(); + scope.panelRenderingComplete(); }); function setElementHeight() { diff --git a/public/app/panels/text/module.js b/public/app/panels/text/module.js index c5e82cd4199..436a9982b41 100644 --- a/public/app/panels/text/module.js +++ b/public/app/panels/text/module.js @@ -61,6 +61,7 @@ function (angular, app, _, require, PanelMeta) { else if ($scope.panel.mode === 'text') { $scope.renderText($scope.panel.content); } + $scope.panelRenderingComplete(); }; $scope.renderText = function(content) { diff --git a/public/test/specs/graph-specs.js b/public/test/specs/graph-specs.js index a234323ee01..b29076db9a6 100644 --- a/public/test/specs/graph-specs.js +++ b/public/test/specs/graph-specs.js @@ -36,6 +36,7 @@ define([ } }; + scope.panelRenderingComplete = sinon.spy(); scope.appEvent = sinon.spy(); scope.onAppEvent = sinon.spy(); scope.hiddenSeries = {}; diff --git a/vendor/phantomjs/render.js b/vendor/phantomjs/render.js index 58afcd44eba..33fda200cba 100644 --- a/vendor/phantomjs/render.js +++ b/vendor/phantomjs/render.js @@ -34,10 +34,12 @@ page.open(params.url, function (status) { function checkIsReady() { var canvas = page.evaluate(function() { - return $('canvas').length > 0; + var body = angular.element(document.body); // 1 + var rootScope = body.scope().$root; + return rootScope.performance.panelsRendered > 0; }); - if (canvas || tries === 100) { + if (canvas || tries === 1000) { page.render(params.png); phantom.exit(); }