From ebb373eedb25e1e8682f9cdf8f63e9eb40bd6cb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sat, 9 Apr 2016 14:37:30 -0400 Subject: [PATCH] fix(graph): fixed issue with toggling series on and off would loose stacking, fixes #4557 --- CHANGELOG.md | 1 + public/app/plugins/panel/graph/module.ts | 11 +++-------- .../app/plugins/panel/graph/series_overrides_ctrl.js | 4 ++-- public/test/specs/seriesOverridesCtrl-specs.js | 1 - 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 941245a83f4..041381409ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ * **Graph Panel**: Fixed issue where newly added graph panels shared same axes config, fixes [#4582](https://github.com/grafana/grafana/issues/4582) * **Graph Panel**: Fixed issue with axis labels overlapping Y-axis, fixes [#4626](https://github.com/grafana/grafana/issues/4626) * **InfluxDB**: Fixed issue with templating query containing template variable, fixes [#4602](https://github.com/grafana/grafana/issues/4602) +* **Graph Panel**: Fixed issue with hiding series and stacking, fixes [#4557](https://github.com/grafana/grafana/issues/4557) # 3.0.0-beta2 (2016-04-04) diff --git a/public/app/plugins/panel/graph/module.ts b/public/app/plugins/panel/graph/module.ts index 6fce3b5d81a..c42bc6e6c46 100644 --- a/public/app/plugins/panel/graph/module.ts +++ b/public/app/plugins/panel/graph/module.ts @@ -116,6 +116,7 @@ class GraphCtrl extends MetricsPanelCtrl { this.colors = $scope.$root.colors; + this.events.on('render', this.onRender.bind(this)); this.events.on('data-received', this.onDataReceived.bind(this)); this.events.on('data-error', this.onDataError.bind(this)); this.events.on('data-snapshot-load', this.onDataSnapshotLoad.bind(this)); @@ -215,20 +216,15 @@ class GraphCtrl extends MetricsPanelCtrl { this.panel.tooltip.msResolution = this.panel.tooltip.msResolution || series.isMsResolutionNeeded(); } - series.applySeriesOverrides(this.panel.seriesOverrides); return series; } - seriesOverrideChanged() { - if (!this.seriesList) { - return; - } + onRender() { + if (!this.seriesList) { return; } for (let series of this.seriesList) { series.applySeriesOverrides(this.panel.seriesOverrides); } - - this.render(); } changeSeriesColor(series, color) { @@ -247,7 +243,6 @@ class GraphCtrl extends MetricsPanelCtrl { } else { this.toggleSeriesExclusiveMode(serie); } - this.render(); } diff --git a/public/app/plugins/panel/graph/series_overrides_ctrl.js b/public/app/plugins/panel/graph/series_overrides_ctrl.js index 0ecedde8595..7a41a650306 100644 --- a/public/app/plugins/panel/graph/series_overrides_ctrl.js +++ b/public/app/plugins/panel/graph/series_overrides_ctrl.js @@ -43,7 +43,7 @@ define([ } $scope.updateCurrentOverrides(); - $scope.ctrl.seriesOverrideChanged(); + $scope.ctrl.render(); }; $scope.colorSelected = function(color) { @@ -62,7 +62,7 @@ define([ colorSelected: $scope.colorSelected, }, onClose: function() { - $scope.ctrl.seriesOverrideChanged(); + $scope.ctrl.render(); } }); }; diff --git a/public/test/specs/seriesOverridesCtrl-specs.js b/public/test/specs/seriesOverridesCtrl-specs.js index d468b649573..f83a87d5977 100644 --- a/public/test/specs/seriesOverridesCtrl-specs.js +++ b/public/test/specs/seriesOverridesCtrl-specs.js @@ -22,7 +22,6 @@ define([ ctx.scope.ctrl = { refresh: sinon.spy(), render: sinon.spy(), - seriesOverrideChanged: sinon.spy(), seriesList: [] }; ctx.scope.render = function() {};