|
@@ -1,5 +1,7 @@
|
|
|
import { describe, it, expect } from '../../../../../test/lib/common';
|
|
import { describe, it, expect } from '../../../../../test/lib/common';
|
|
|
|
|
|
|
|
|
|
+import angular from 'angular';
|
|
|
|
|
+import TimeSeries from 'app/core/time_series2';
|
|
|
import { ThresholdManager } from '../threshold_manager';
|
|
import { ThresholdManager } from '../threshold_manager';
|
|
|
|
|
|
|
|
describe('ThresholdManager', function() {
|
|
describe('ThresholdManager', function() {
|
|
@@ -15,9 +17,13 @@ describe('ThresholdManager', function() {
|
|
|
panelCtrl: {},
|
|
panelCtrl: {},
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- ctx.setup = function(thresholds) {
|
|
|
|
|
|
|
+ ctx.setup = function(thresholds, data) {
|
|
|
ctx.panel.thresholds = thresholds;
|
|
ctx.panel.thresholds = thresholds;
|
|
|
var manager = new ThresholdManager(ctx.panelCtrl);
|
|
var manager = new ThresholdManager(ctx.panelCtrl);
|
|
|
|
|
+ if (data !== undefined) {
|
|
|
|
|
+ var element = angular.element('<div grafana-graph><div>');
|
|
|
|
|
+ manager.prepare(element, data);
|
|
|
|
|
+ }
|
|
|
manager.addFlotOptions(ctx.options, ctx.panel);
|
|
manager.addFlotOptions(ctx.options, ctx.panel);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -101,5 +107,36 @@ describe('ThresholdManager', function() {
|
|
|
expect(markings[1].yaxis.to).to.be(-Infinity);
|
|
expect(markings[1].yaxis.to).to.be(-Infinity);
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+ plotOptionsScenario('for threshold on two Y axes', ctx => {
|
|
|
|
|
+ var data = new Array(2);
|
|
|
|
|
+ data[0] = new TimeSeries({
|
|
|
|
|
+ datapoints: [[0, 1], [300, 2]],
|
|
|
|
|
+ alias: 'left',
|
|
|
|
|
+ });
|
|
|
|
|
+ data[0].yaxis = 1;
|
|
|
|
|
+ data[1] = new TimeSeries({
|
|
|
|
|
+ datapoints: [[0, 1], [300, 2]],
|
|
|
|
|
+ alias: 'right',
|
|
|
|
|
+ });
|
|
|
|
|
+ data[1].yaxis = 2;
|
|
|
|
|
+ ctx.setup(
|
|
|
|
|
+ [
|
|
|
|
|
+ { op: 'gt', value: 100, line: true, colorMode: 'critical' },
|
|
|
|
|
+ { op: 'gt', value: 200, line: true, colorMode: 'critical', yaxis: 'right' },
|
|
|
|
|
+ ],
|
|
|
|
|
+ data
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ it('should add first threshold for left axis', function() {
|
|
|
|
|
+ var markings = ctx.options.grid.markings;
|
|
|
|
|
+ expect(markings[0].yaxis.from).to.be(100);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('should add second threshold for right axis', function() {
|
|
|
|
|
+ var markings = ctx.options.grid.markings;
|
|
|
|
|
+ expect(markings[1].y2axis.from).to.be(200);
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|