Commit 468c9a90 by Torkel Ödegaard

Fix for zindex override removal, should restore series order

parent da1279aa
......@@ -9,7 +9,6 @@ function (_, kbn) {
this.datapoints = opts.datapoints;
this.info = opts.info;
this.label = opts.info.alias;
this.zindex = 0;
}
function matchSeriesOverride(aliasOrRegex, seriesAlias) {
......@@ -31,6 +30,7 @@ function (_, kbn) {
this.points = {};
this.bars = {};
this.info.yaxis = 1;
this.zindex = 0;
delete this.stack;
for (var i = 0; i < overrides.length; i++) {
......
......@@ -168,19 +168,19 @@ function (angular, $, kbn, moment, _) {
addAnnotations(options);
configureAxisOptions(data, options);
data = _.sortBy(data, function(series) { return series.zindex; });
var sortedSeries = _.sortBy(data, function(series) { return series.zindex; });
// if legend is to the right delay plot draw a few milliseconds
// so the legend width calculation can be done
if (shouldDelayDraw(panel)) {
legendSideLastValue = panel.legend.rightSide;
setTimeout(function() {
plot = $.plot(elem, data, options);
plot = $.plot(elem, sortedSeries, options);
addAxisLabels();
}, 50);
}
else {
plot = $.plot(elem, data, options);
plot = $.plot(elem, sortedSeries, options);
addAxisLabels();
}
}
......
......@@ -66,16 +66,14 @@
<div class="editor-row">
<div class="section">
<h5>Series specific overrides <tip>Regex match example: /server[0-3]/i </tip></h5>
<div>
<div class="grafana-target" ng-repeat="override in panel.seriesOverrides" ng-controller="SeriesOverridesCtrl">
<div class="grafana-target-inner-wrapper">
<div class="grafana-target-inner">
<ul class="grafana-target-controls-left">
<li>
<a class="grafana-target-segment" ng-click="removeSeriesOverride(override)" role="menuitem">
<i class="icon-remove"></i>
</a>
<li class="grafana-target-segment>"
<i class="icon-remove" ng-click="removeSeriesOverride(override)"></i>
</li>
</ul>
......@@ -90,9 +88,7 @@
class="input-medium grafana-target-segment-input" >
</li>
<li class="grafana-target-segment" ng-repeat="option in currentOverrides">
<a class="pointer" ng-click="removeOverride(option)">
<i class="icon-remove"></i>
</a>
<i class="pointer icon-remove" ng-click="removeOverride(option)"></i>
{{option.name}}: {{option.value}}
</li>
<li class="dropdown">
......@@ -105,6 +101,7 @@
</div>
</div>
</div>
</div>
<button class="btn btn-success" style="margin-top: 20px" ng-click="addSeriesOverride()">Add series override rule</button>
</div>
......
......@@ -92,8 +92,8 @@ define([
});
graphScenario('should order series order according to zindex', function(ctx) {
ctx.setup(function(scope, data) {
data[0].zindex = 2;
ctx.setup(function(scope) {
scope.panel.seriesOverrides = [{ alias: 'series1', zindex: 2 }];
});
it('should move zindex 2 last', function() {
......
......@@ -101,8 +101,8 @@ define([
it('should set yaxis', function() {
expect(series.info.yaxis).to.be(2);
});
it('should set zindex', function() {
expect(series.zindex).to.be(2);
});
......
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