Commit cdcbb872 by Torkel Ödegaard

options per series is starting to work nicely

parent 04876305
...@@ -184,16 +184,24 @@ function (angular, $, kbn, moment, _) { ...@@ -184,16 +184,24 @@ function (angular, $, kbn, moment, _) {
} }
function applySeriesOverrideOptions(series) { function applySeriesOverrideOptions(series) {
series.lines = {};
series.points = {};
series.bars = {};
for (var i = 0; i < scope.panel.seriesOverrides.length; i++) { for (var i = 0; i < scope.panel.seriesOverrides.length; i++) {
var override = scope.panel.seriesOverrides[i]; var override = scope.panel.seriesOverrides[i];
if (override.alias === series.info.alias) { if (override.alias !== series.info.alias) {
if (!_.isUndefined(override.fill)) { continue;
series.lines = {
fill: override.fill === 0 ? 0.001 : override.fill/10
};
} }
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) { function shouldDelayDraw(panel) {
......
...@@ -352,6 +352,7 @@ function (angular, app, $, _, kbn, moment, TimeSeries) { ...@@ -352,6 +352,7 @@ function (angular, app, $, _, kbn, moment, TimeSeries) {
$scope.removeSeriesOverride = function(override) { $scope.removeSeriesOverride = function(override) {
$scope.panel.seriesOverrides = _.without($scope.panel.seriesOverrides, override); $scope.panel.seriesOverrides = _.without($scope.panel.seriesOverrides, override);
$scope.render();
}; };
panelSrv.init($scope); panelSrv.init($scope);
......
...@@ -41,6 +41,7 @@ define([ ...@@ -41,6 +41,7 @@ define([
$scope.removeOverride = function(option) { $scope.removeOverride = function(option) {
delete $scope.override[option.propertyName]; delete $scope.override[option.propertyName];
$scope.updateCurrentOverrides(); $scope.updateCurrentOverrides();
$scope.render();
}; };
$scope.updateCurrentOverrides = function() { $scope.updateCurrentOverrides = function() {
...@@ -59,7 +60,8 @@ define([ ...@@ -59,7 +60,8 @@ define([
$scope.addOverrideOption('Bars', 'bars', [true, false]); $scope.addOverrideOption('Bars', 'bars', [true, false]);
$scope.addOverrideOption('Lines', 'lines', [true, false]); $scope.addOverrideOption('Lines', 'lines', [true, false]);
$scope.addOverrideOption('Points', 'points', [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(); $scope.updateCurrentOverrides();
}); });
......
...@@ -84,7 +84,10 @@ ...@@ -84,7 +84,10 @@
alias or regex alias or regex
</li> </li>
<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>
<li class="grafana-target-segment" ng-repeat="option in currentOverrides"> <li class="grafana-target-segment" ng-repeat="option in currentOverrides">
<a class="pointer" ng-click="removeOverride(option)"> <a class="pointer" ng-click="removeOverride(option)">
......
...@@ -74,23 +74,41 @@ define([ ...@@ -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) { ctx.setup(function(scope, data) {
scope.panel.lines = true; scope.panel.lines = true;
scope.panel.fill = 5; scope.panel.fill = 5;
scope.panel.seriesOverrides = [ scope.panel.seriesOverrides = [
{ alias: 'test', fill: 0 } { alias: 'test', fill: 0, points: true }
]; ];
data[1].info.alias = 'test'; 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.plotOptions.series.lines.fill).to.be(0.5);
expect(ctx.plotData[1].lines.fill).to.be(0.001); 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