Commit af8fec94 by Torkel Ödegaard

Graph: Fix for series draw order not being the same after hiding/unhiding series, Fixes #847

parent 7fe76d32
# 1.9.0 (unreleased)
**Fixes**
- [Issue #847](https://github.com/grafana/grafana/issues/847). Graph: Fix for series draw order not being the same after hiding/unhiding series
# 1.8.0 (2014-09-22) # 1.8.0 (2014-09-22)
Read this [blog post](http://grafana.org/blog/2014/09/11/grafana-1-8-0-rc1-released.html) for an overview of all improvements. Read this [blog post](http://grafana.org/blog/2014/09/11/grafana-1-8-0-rc1-released.html) for an overview of all improvements.
......
...@@ -16,7 +16,6 @@ function (angular, $, kbn, moment, _) { ...@@ -16,7 +16,6 @@ function (angular, $, kbn, moment, _) {
template: '<div> </div>', template: '<div> </div>',
link: function(scope, elem) { link: function(scope, elem) {
var data, annotations; var data, annotations;
var hiddenData = {};
var dashboard = scope.dashboard; var dashboard = scope.dashboard;
var legendSideLastValue = null; var legendSideLastValue = null;
...@@ -24,14 +23,7 @@ function (angular, $, kbn, moment, _) { ...@@ -24,14 +23,7 @@ function (angular, $, kbn, moment, _) {
scope.get_data(); scope.get_data();
}); });
scope.$on('toggleLegend', function(e, series) { scope.$on('toggleLegend', function() {
_.each(series, function(serie) {
if (hiddenData[serie.alias]) {
data.push(hiddenData[serie.alias]);
delete hiddenData[serie.alias];
}
});
render_panel(); render_panel();
}); });
...@@ -95,17 +87,6 @@ function (angular, $, kbn, moment, _) { ...@@ -95,17 +87,6 @@ function (angular, $, kbn, moment, _) {
} }
var panel = scope.panel; var panel = scope.panel;
_.each(_.keys(scope.hiddenSeries), function(seriesAlias) {
var dataSeries = _.find(data, function(series) {
return series.info.alias === seriesAlias;
});
if (dataSeries) {
hiddenData[dataSeries.info.alias] = dataSeries;
data = _.without(data, dataSeries);
}
});
var stack = panel.stack ? true : null; var stack = panel.stack ? true : null;
// Populate element // Populate element
...@@ -156,6 +137,11 @@ function (angular, $, kbn, moment, _) { ...@@ -156,6 +137,11 @@ function (angular, $, kbn, moment, _) {
var series = data[i]; var series = data[i];
series.applySeriesOverrides(panel.seriesOverrides); series.applySeriesOverrides(panel.seriesOverrides);
series.data = series.getFlotPairs(panel.nullPointMode, panel.y_formats); series.data = series.getFlotPairs(panel.nullPointMode, panel.y_formats);
// if hidden remove points and disable stack
if (scope.hiddenSeries[series.info.alias]) {
series.data = [];
series.stack = false;
}
} }
if (data.length && data[0].info.timeStep) { if (data.length && data[0].info.timeStep) {
......
...@@ -29,6 +29,7 @@ define([ ...@@ -29,6 +29,7 @@ define([
y_formats: [], y_formats: [],
seriesOverrides: [] seriesOverrides: []
}; };
scope.hiddenSeries = {};
scope.dashboard = { timezone: 'browser' }; scope.dashboard = { timezone: 'browser' };
scope.range = { scope.range = {
from: new Date('2014-08-09 10:00:00'), from: new Date('2014-08-09 10:00:00'),
...@@ -145,6 +146,18 @@ define([ ...@@ -145,6 +146,18 @@ define([
}); });
}); });
graphScenario('when series is hidden', function(ctx) {
ctx.setup(function(scope) {
scope.hiddenSeries = {'series2': true};
});
it('should remove datapoints and disable stack', function() {
expect(ctx.plotData[0].info.alias).to.be('series1');
expect(ctx.plotData[1].data.length).to.be(0);
expect(ctx.plotData[1].stack).to.be(false);
});
});
}); });
}); });
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