Commit b2f9f81e by Torkel Ödegaard

Moved yaxis override from aliasYAxis map to the new seriesOverride array

parent 939e957f
...@@ -212,6 +212,10 @@ function (angular, $, kbn, moment, _) { ...@@ -212,6 +212,10 @@ function (angular, $, kbn, moment, _) {
if (override.linewidth !== void 0) { series.lines.lineWidth = override.linewidth; } if (override.linewidth !== void 0) { series.lines.lineWidth = override.linewidth; }
if (override.pointradius !== void 0) { series.points.radius = override.pointradius; } if (override.pointradius !== void 0) { series.points.radius = override.pointradius; }
if (override.steppedLine !== void 0) { series.lines.steps = override.steppedLine; } if (override.steppedLine !== void 0) { series.lines.steps = override.steppedLine; }
if (override.yaxis !== void 0) {
series.yaxis = override.yaxis;
series.info.yaxis = override.yaxis;
}
} }
} }
......
...@@ -166,7 +166,6 @@ function (angular, app, $, _, kbn, moment, TimeSeries) { ...@@ -166,7 +166,6 @@ function (angular, app, $, _, kbn, moment, TimeSeries) {
targets: [{}], targets: [{}],
aliasColors: {}, aliasColors: {},
aliasYAxis: {},
seriesOverrides: [], seriesOverrides: [],
}; };
...@@ -247,13 +246,10 @@ function (angular, app, $, _, kbn, moment, TimeSeries) { ...@@ -247,13 +246,10 @@ function (angular, app, $, _, kbn, moment, TimeSeries) {
var datapoints = seriesData.datapoints; var datapoints = seriesData.datapoints;
var alias = seriesData.target; var alias = seriesData.target;
var color = $scope.panel.aliasColors[alias] || $rootScope.colors[index]; var color = $scope.panel.aliasColors[alias] || $rootScope.colors[index];
var yaxis = $scope.panel.aliasYAxis[alias] || 1;
var seriesInfo = { var seriesInfo = {
alias: alias, alias: alias,
color: color, color: color,
enable: true,
yaxis: yaxis
}; };
$scope.legend.push(seriesInfo); $scope.legend.push(seriesInfo);
...@@ -336,8 +332,12 @@ function (angular, app, $, _, kbn, moment, TimeSeries) { ...@@ -336,8 +332,12 @@ function (angular, app, $, _, kbn, moment, TimeSeries) {
}; };
$scope.toggleYAxis = function(info) { $scope.toggleYAxis = function(info) {
info.yaxis = info.yaxis === 2 ? 1 : 2; var override = _.findWhere($scope.panel.seriesOverrides, { alias: info.alias });
$scope.panel.aliasYAxis[info.alias] = info.yaxis; if (!override) {
override = { alias: info.alias };
$scope.panel.seriesOverrides.push(override);
}
override.yaxis = info.yaxis === 2 ? 1 : 2;
$scope.render(); $scope.render();
}; };
......
...@@ -65,6 +65,7 @@ define([ ...@@ -65,6 +65,7 @@ define([
$scope.addOverrideOption('Points', 'points', [true, false]); $scope.addOverrideOption('Points', 'points', [true, false]);
$scope.addOverrideOption('Points Radius', 'pointradius', [1,2,3,4,5]); $scope.addOverrideOption('Points Radius', 'pointradius', [1,2,3,4,5]);
$scope.addOverrideOption('Stack', 'stack', [true, false]); $scope.addOverrideOption('Stack', 'stack', [true, false]);
$scope.addOverrideOption('Y-axis', 'yaxis', [1, 2]);
$scope.updateCurrentOverrides(); $scope.updateCurrentOverrides();
}); });
......
...@@ -144,33 +144,17 @@ function (angular, $, kbn, _, moment) { ...@@ -144,33 +144,17 @@ function (angular, $, kbn, _, moment) {
}; };
p.updateSchema = function(old) { p.updateSchema = function(old) {
var i, j, row, panel;
var oldVersion = this.version; var oldVersion = this.version;
this.version = 3; var panelUpgrades = [];
this.version = 4;
if (oldVersion === 3) { if (oldVersion === 4) {
return; return;
} }
// Version 3 schema changes // version 2 schema changes
// ensure panel ids if (oldVersion < 2) {
var maxId = this.getNextPanelId();
for (i = 0; i < this.rows.length; i++) {
row = this.rows[i];
for (j = 0; j < row.panels.length; j++) {
panel = row.panels[j];
if (!panel.id) {
panel.id = maxId;
maxId += 1;
}
}
}
if (oldVersion === 2) {
return;
}
// Version 2 schema changes
if (old.services) { if (old.services) {
if (old.services.filter) { if (old.services.filter) {
this.time = old.services.filter.time; this.time = old.services.filter.time;
...@@ -179,19 +163,18 @@ function (angular, $, kbn, _, moment) { ...@@ -179,19 +163,18 @@ function (angular, $, kbn, _, moment) {
delete this.services; delete this.services;
} }
for (i = 0; i < this.rows.length; i++) { panelUpgrades.push(function(panel) {
row = this.rows[i]; // rename panel type
for (j = 0; j < row.panels.length; j++) {
panel = row.panels[j];
if (panel.type === 'graphite') { if (panel.type === 'graphite') {
panel.type = 'graph'; panel.type = 'graph';
} }
if (panel.type === 'graph') { if (panel.type !== 'graph') {
if (_.isBoolean(panel.legend)) { return;
panel.legend = { show: panel.legend };
} }
if (_.isBoolean(panel.legend)) { panel.legend = { show: panel.legend }; }
if (panel.grid) { if (panel.grid) {
if (panel.grid.min) { if (panel.grid.min) {
panel.grid.leftMin = panel.grid.min; panel.grid.leftMin = panel.grid.min;
...@@ -213,11 +196,45 @@ function (angular, $, kbn, _, moment) { ...@@ -213,11 +196,45 @@ function (angular, $, kbn, _, moment) {
panel.y_formats[1] = panel.y2_format; panel.y_formats[1] = panel.y2_format;
delete panel.y2_format; delete panel.y2_format;
} }
});
} }
// schema version 3 changes
if (oldVersion < 3) {
// ensure panel ids
var maxId = this.getNextPanelId();
panelUpgrades.push(function(panel) {
if (!panel.id) {
panel.id = maxId;
maxId += 1;
} }
});
} }
this.version = 3; // schema version 4 changes
if (oldVersion < 4) {
// move aliasYAxis changes
panelUpgrades.push(function(panel) {
if (panel.type !== 'graph') { return; }
_.each(panel.aliasYAxis, function(value, key) {
panel.seriesOverrides = [{ alias: key, yaxis: value }];
});
delete panel.aliasYAxis;
});
}
if (panelUpgrades.length === 0) {
return;
}
for (var i = 0; i < this.rows.length; i++) {
var row = this.rows[i];
for (var j = 0; j < row.panels.length; j++) {
for (var k = 0; k < panelUpgrades.length; k++) {
panelUpgrades[k](row.panels[j]);
}
}
}
}; };
return { return {
......
...@@ -97,6 +97,7 @@ define([ ...@@ -97,6 +97,7 @@ define([
{ {
type: 'graphite', type: 'graphite',
legend: true, legend: true,
aliasYAxis: { test: 2 },
grid: { min: 1, max: 10 } grid: { min: 1, max: 10 }
} }
] ]
...@@ -134,8 +135,13 @@ define([ ...@@ -134,8 +135,13 @@ define([
expect(graph.grid.leftMax).to.be(10); expect(graph.grid.leftMax).to.be(10);
}); });
it('move aliasYAxis to series override', function() {
expect(graph.seriesOverrides[0].alias).to.be("test");
expect(graph.seriesOverrides[0].yaxis).to.be(2);
});
it('dashboard schema version should be set to latest', function() { it('dashboard schema version should be set to latest', function() {
expect(model.version).to.be(3); expect(model.version).to.be(4);
}); });
}); });
......
...@@ -153,12 +153,27 @@ define([ ...@@ -153,12 +153,27 @@ define([
data[1].info.alias = 'test_01'; data[1].info.alias = 'test_01';
}); });
it('should match second series and set pointradius, and set steppedLine', function() { it('should match second series', function() {
expect(ctx.plotData[0].lines.show).to.be(undefined); expect(ctx.plotData[0].lines.show).to.be(undefined);
expect(ctx.plotData[1].lines.show).to.be(false); expect(ctx.plotData[1].lines.show).to.be(false);
}); });
}); });
graphScenario('override series y-axis', function(ctx) {
ctx.setup(function(scope, data) {
scope.panel.lines = true;
scope.panel.seriesOverrides = [
{ alias: 'test', yaxis: 2 }
];
data[1].info.alias = 'test';
});
it('should match second series and set yaxis', function() {
expect(ctx.plotData[1].yaxis).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