Added zindex per series override option, #425

This commit is contained in:
Torkel Ödegaard 2014-08-20 10:50:26 +02:00
parent 3ec053bea7
commit da1279aa5b
5 changed files with 22 additions and 3 deletions

View File

@ -9,6 +9,7 @@ function (_, kbn) {
this.datapoints = opts.datapoints;
this.info = opts.info;
this.label = opts.info.alias;
this.zindex = 0;
}
function matchSeriesOverride(aliasOrRegex, seriesAlias) {
@ -45,6 +46,7 @@ function (_, kbn) {
if (override.linewidth !== void 0) { this.lines.lineWidth = override.linewidth; }
if (override.pointradius !== void 0) { this.points.radius = override.pointradius; }
if (override.steppedLine !== void 0) { this.lines.steps = override.steppedLine; }
if (override.zindex !== void 0) { this.zindex = override.zindex; }
if (override.yaxis !== void 0) {
this.info.yaxis = override.yaxis;
}

View File

@ -168,6 +168,8 @@ function (angular, $, kbn, moment, _) {
addAnnotations(options);
configureAxisOptions(data, options);
data = _.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)) {

View File

@ -66,6 +66,7 @@ define([
$scope.addOverrideOption('Points Radius', 'pointradius', [1,2,3,4,5]);
$scope.addOverrideOption('Stack', 'stack', [true, false]);
$scope.addOverrideOption('Y-axis', 'yaxis', [1, 2]);
$scope.addOverrideOption('Z-index', 'zindex', [-1,-2,-3,0,1,2,3]);
$scope.updateCurrentOverrides();
});

View File

@ -71,7 +71,6 @@ define([
expect(ctx.plotOptions.series.lines.lineWidth).to.be(3);
expect(ctx.plotOptions.series.lines.steps).to.be(true);
});
});
graphScenario('series option overrides, fill & points', function(ctx) {
@ -92,6 +91,17 @@ define([
});
});
graphScenario('should order series order according to zindex', function(ctx) {
ctx.setup(function(scope, data) {
data[0].zindex = 2;
});
it('should move zindex 2 last', function() {
expect(ctx.plotData[0].info.alias).to.be('series2');
expect(ctx.plotData[1].info.alias).to.be('series1');
});
});
});
});

View File

@ -93,14 +93,18 @@ define([
});
});
describe('override series y-axis', function() {
describe('override series y-axis, and z-index', function() {
beforeEach(function() {
series.info.alias = 'test';
series.applySeriesOverrides([{ alias: 'test', yaxis: 2 }]);
series.applySeriesOverrides([{ alias: 'test', yaxis: 2, zindex: 2 }]);
});
it('should set yaxis', function() {
expect(series.info.yaxis).to.be(2);
});
it('should set zindex', function() {
expect(series.zindex).to.be(2);
});
});