Commit cdcbb872 by Torkel Ödegaard

options per series is starting to work nicely

parent 04876305
......@@ -184,16 +184,24 @@ function (angular, $, kbn, moment, _) {
}
function applySeriesOverrideOptions(series) {
series.lines = {};
series.points = {};
series.bars = {};
for (var i = 0; i < scope.panel.seriesOverrides.length; i++) {
var override = scope.panel.seriesOverrides[i];
if (override.alias === series.info.alias) {
if (!_.isUndefined(override.fill)) {
series.lines = {
fill: override.fill === 0 ? 0.001 : override.fill/10
};
if (override.alias !== series.info.alias) {
continue;
}
if (override.lines !== void 0) { series.lines.show = override.lines; }
if (override.points !== void 0) { series.points.show = override.points; }
if (override.bars !== void 0) { series.bars.show = override.bars; }
if (override.fill !== void 0) { series.lines.fill = translateFillOption(override.fill); }
}
}
function translateFillOption(fill) {
return fill === 0 ? 0.001 : fill/10;
}
function shouldDelayDraw(panel) {
......
......@@ -352,6 +352,7 @@ function (angular, app, $, _, kbn, moment, TimeSeries) {
$scope.removeSeriesOverride = function(override) {
$scope.panel.seriesOverrides = _.without($scope.panel.seriesOverrides, override);
$scope.render();
};
panelSrv.init($scope);
......
......@@ -41,6 +41,7 @@ define([
$scope.removeOverride = function(option) {
delete $scope.override[option.propertyName];
$scope.updateCurrentOverrides();
$scope.render();
};
$scope.updateCurrentOverrides = function() {
......@@ -59,7 +60,8 @@ define([
$scope.addOverrideOption('Bars', 'bars', [true, false]);
$scope.addOverrideOption('Lines', 'lines', [true, false]);
$scope.addOverrideOption('Points', 'points', [true, false]);
$scope.addOverrideOption('Line fill', 'fill', [1,2,3,4,5,6,7,8]);
$scope.addOverrideOption('Line fill', 'fill', [0,1,2,3,4,5,6,7,8,9,10]);
$scope.addOverrideOption('Line width', 'linewidth', [0,1,2,3,4,5,6,7,8,9,10]);
$scope.updateCurrentOverrides();
});
......
......@@ -84,7 +84,10 @@
alias or regex
</li>
<li>
<input type="text" ng-model="override.alias" class="input-medium grafana-target-segment-input" >
<input type="text"
ng-model="override.alias"
ng-model-onblur ng-change="render()"
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)">
......
......@@ -74,23 +74,41 @@ define([
});
graphScenario('series option fill override', function(ctx) {
graphScenario('series option overrides, fill & points', function(ctx) {
ctx.setup(function(scope, data) {
scope.panel.lines = true;
scope.panel.fill = 5;
scope.panel.seriesOverrides = [
{ alias: 'test', fill: 0 }
{ alias: 'test', fill: 0, points: true }
];
data[1].info.alias = 'test';
});
it('should match second series and set line fill', function() {
it('should match second series and fill zero, and enable points', function() {
expect(ctx.plotOptions.series.lines.fill).to.be(0.5);
expect(ctx.plotData[1].lines.fill).to.be(0.001);
expect(ctx.plotData[1].points.show).to.be(true);
});
});
graphScenario('series option overrides, bars, true & lines false', function(ctx) {
ctx.setup(function(scope, data) {
scope.panel.lines = true;
scope.panel.seriesOverrides = [
{ alias: 'test', bars: true, lines: false }
];
data[1].info.alias = 'test';
});
it('should match second series and disable lines, and enable bars', function() {
expect(ctx.plotOptions.series.lines.show).to.be(true);
expect(ctx.plotData[1].lines.show).to.be(false);
expect(ctx.plotData[1].bars.show).to.be(true);
});
});
});
});
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