|
|
@@ -75,7 +75,7 @@ describe('grafanaGraph', function() {
|
|
|
alias: 'series1'
|
|
|
}));
|
|
|
ctx.data.push(new TimeSeries({
|
|
|
- datapoints: [[1,10],[2,20]],
|
|
|
+ datapoints: [[10,1],[20,2]],
|
|
|
alias: 'series2'
|
|
|
}));
|
|
|
|
|
|
@@ -112,52 +112,67 @@ describe('grafanaGraph', function() {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- graphScenario('sort series as legend', (ctx) => {
|
|
|
- describe("with sort as legend undefined", () => {
|
|
|
- ctx.setup((ctrl) => {
|
|
|
- ctrl.panel.legend.sort = undefined;
|
|
|
- });
|
|
|
+ graphScenario('sorting stacked series as legend. disabled', (ctx) => {
|
|
|
+ ctx.setup((ctrl) => {
|
|
|
+ ctrl.panel.legend.sort = undefined;
|
|
|
+ ctrl.panel.stack = false;
|
|
|
+ });
|
|
|
|
|
|
- it("should not modify order of time series", () => {
|
|
|
- expect(ctx.plotData[0].alias).to.be('series1');
|
|
|
- expect(ctx.plotData[1].alias).to.be('series2');
|
|
|
- });
|
|
|
+ it("should not modify order of time series", () => {
|
|
|
+ expect(ctx.plotData[0].alias).to.be('series1');
|
|
|
+ expect(ctx.plotData[1].alias).to.be('series2');
|
|
|
});
|
|
|
+ });
|
|
|
|
|
|
- describe("with sort as legend set to min. descending order", () => {
|
|
|
- ctx.setup((ctrl) => {
|
|
|
- ctrl.panel.legend.sort = 'min';
|
|
|
- ctrl.panel.legend.sortDesc = true;
|
|
|
- });
|
|
|
+ graphScenario("sorting stacked series as legend. min descending order", (ctx) => {
|
|
|
+ ctx.setup(ctrl => {
|
|
|
+ ctrl.panel.legend.sort = 'min';
|
|
|
+ ctrl.panel.legend.sortDesc = true;
|
|
|
+ ctrl.panel.stack = true;
|
|
|
+ });
|
|
|
|
|
|
- it("highest value should be first", () => {
|
|
|
- expect(ctx.plotData[1].alias).to.be('series2');
|
|
|
- expect(ctx.plotData[0].alias).to.be('series1');
|
|
|
- });
|
|
|
+ it("highest value should be first", () => {
|
|
|
+ expect(ctx.plotData[0].alias).to.be('series2');
|
|
|
+ expect(ctx.plotData[1].alias).to.be('series1');
|
|
|
});
|
|
|
+ });
|
|
|
|
|
|
- describe("with sort as legend set to min. ascending order", () => {
|
|
|
- ctx.setup((ctrl) => {
|
|
|
- ctrl.panel.legend.sort = 'min';
|
|
|
- ctrl.panel.legend.sortDesc = true;
|
|
|
- });
|
|
|
+ graphScenario("sorting stacked series as legend. min ascending order", (ctx) => {
|
|
|
+ ctx.setup((ctrl, data) => {
|
|
|
+ ctrl.panel.legend.sort = 'min';
|
|
|
+ ctrl.panel.legend.sortDesc = false;
|
|
|
+ ctrl.panel.stack = true;
|
|
|
+ });
|
|
|
|
|
|
- it("lowest value should be first", () => {
|
|
|
- expect(ctx.plotData[0].alias).to.be('series1');
|
|
|
- expect(ctx.plotData[1].alias).to.be('series2');
|
|
|
- });
|
|
|
+ it("lowest value should be first", () => {
|
|
|
+ expect(ctx.plotData[0].alias).to.be('series1');
|
|
|
+ expect(ctx.plotData[1].alias).to.be('series2');
|
|
|
});
|
|
|
+ });
|
|
|
|
|
|
- describe("with sort as legend set to current. ascending order", () => {
|
|
|
- ctx.setup((ctrl) => {
|
|
|
- ctrl.panel.legend.sort = 'current';
|
|
|
- ctrl.panel.legend.sortDesc = false;
|
|
|
- });
|
|
|
+ graphScenario("sorting stacked series as legend. stacking disabled", (ctx) => {
|
|
|
+ ctx.setup((ctrl) => {
|
|
|
+ ctrl.panel.legend.sort = 'min';
|
|
|
+ ctrl.panel.legend.sortDesc = true;
|
|
|
+ ctrl.panel.stack = false;
|
|
|
+ });
|
|
|
|
|
|
- it("highest last value should be first", () => {
|
|
|
- expect(ctx.plotData[1].alias).to.be('series2');
|
|
|
- expect(ctx.plotData[0].alias).to.be('series1');
|
|
|
- });
|
|
|
+ it("highest value should be first", () => {
|
|
|
+ expect(ctx.plotData[0].alias).to.be('series1');
|
|
|
+ expect(ctx.plotData[1].alias).to.be('series2');
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ graphScenario("sorting stacked series as legend. current descending order", (ctx) => {
|
|
|
+ ctx.setup((ctrl) => {
|
|
|
+ ctrl.panel.legend.sort = 'current';
|
|
|
+ ctrl.panel.legend.sortDesc = true;
|
|
|
+ ctrl.panel.stack = true;
|
|
|
+ });
|
|
|
+
|
|
|
+ it("highest last value should be first", () => {
|
|
|
+ expect(ctx.plotData[0].alias).to.be('series2');
|
|
|
+ expect(ctx.plotData[1].alias).to.be('series1');
|
|
|
});
|
|
|
});
|
|
|
|
|
|
@@ -300,7 +315,7 @@ describe('grafanaGraph', function() {
|
|
|
});
|
|
|
|
|
|
it('should set barWidth', function() {
|
|
|
- expect(ctx.plotOptions.series.bars.barWidth).to.be(10/1.5);
|
|
|
+ expect(ctx.plotOptions.series.bars.barWidth).to.be(1/1.5);
|
|
|
});
|
|
|
});
|
|
|
|
|
|
@@ -383,146 +398,4 @@ describe('grafanaGraph', function() {
|
|
|
});
|
|
|
|
|
|
}, 10);
|
|
|
-
|
|
|
- // graphScenario('when using flexible Y-Min and Y-Max settings', function(ctx) {
|
|
|
- // describe('and Y-Min is <100 and Y-Max is >200 and values within range', function() {
|
|
|
- // ctx.setup(function(ctrl, data) {
|
|
|
- // ctrl.panel.yaxes[0].min = '<100';
|
|
|
- // ctrl.panel.yaxes[0].max = '>200';
|
|
|
- // data[0] = new TimeSeries({
|
|
|
- // datapoints: [[120,10],[160,20]],
|
|
|
- // alias: 'series1',
|
|
|
- // });
|
|
|
- // });
|
|
|
- //
|
|
|
- // it('should set min to 100 and max to 200', function() {
|
|
|
- // expect(ctx.plotOptions.yaxes[0].min).to.be(100);
|
|
|
- // expect(ctx.plotOptions.yaxes[0].max).to.be(200);
|
|
|
- // });
|
|
|
- // });
|
|
|
- // describe('and Y-Min is <100 and Y-Max is >200 and values outside range', function() {
|
|
|
- // ctx.setup(function(ctrl, data) {
|
|
|
- // ctrl.panel.yaxes[0].min = '<100';
|
|
|
- // ctrl.panel.yaxes[0].max = '>200';
|
|
|
- // data[0] = new TimeSeries({
|
|
|
- // datapoints: [[99,10],[201,20]],
|
|
|
- // alias: 'series1',
|
|
|
- // });
|
|
|
- // });
|
|
|
- //
|
|
|
- // it('should set min to auto and max to auto', function() {
|
|
|
- // expect(ctx.plotOptions.yaxes[0].min).to.be(null);
|
|
|
- // expect(ctx.plotOptions.yaxes[0].max).to.be(null);
|
|
|
- // });
|
|
|
- // });
|
|
|
- // describe('and Y-Min is =10.5 and Y-Max is =10.5', function() {
|
|
|
- // ctx.setup(function(ctrl, data) {
|
|
|
- // ctrl.panel.yaxes[0].min = '=10.5';
|
|
|
- // ctrl.panel.yaxes[0].max = '=10.5';
|
|
|
- // data[0] = new TimeSeries({
|
|
|
- // datapoints: [[100,10],[120,20], [110,30]],
|
|
|
- // alias: 'series1',
|
|
|
- // });
|
|
|
- // });
|
|
|
- //
|
|
|
- // it('should set min to last value + 10.5 and max to last value + 10.5', function() {
|
|
|
- // expect(ctx.plotOptions.yaxes[0].min).to.be(99.5);
|
|
|
- // expect(ctx.plotOptions.yaxes[0].max).to.be(120.5);
|
|
|
- // });
|
|
|
- // });
|
|
|
- // describe('and Y-Min is ~10.5 and Y-Max is ~10.5', function() {
|
|
|
- // ctx.setup(function(ctrl, data) {
|
|
|
- // ctrl.panel.yaxes[0].min = '~10.5';
|
|
|
- // ctrl.panel.yaxes[0].max = '~10.5';
|
|
|
- // data[0] = new TimeSeries({
|
|
|
- // datapoints: [[102,10],[104,20], [110,30]], //Also checks precision
|
|
|
- // alias: 'series1',
|
|
|
- // });
|
|
|
- // });
|
|
|
- //
|
|
|
- // it('should set min to average value + 10.5 and max to average value + 10.5', function() {
|
|
|
- // expect(ctx.plotOptions.yaxes[0].min).to.be(94.8);
|
|
|
- // expect(ctx.plotOptions.yaxes[0].max).to.be(115.8);
|
|
|
- // });
|
|
|
- // });
|
|
|
- // });
|
|
|
- // graphScenario('when using regular Y-Min and Y-Max settings', function(ctx) {
|
|
|
- // describe('and Y-Min is 100 and Y-Max is 200', function() {
|
|
|
- // ctx.setup(function(ctrl, data) {
|
|
|
- // ctrl.panel.yaxes[0].min = '100';
|
|
|
- // ctrl.panel.yaxes[0].max = '200';
|
|
|
- // data[0] = new TimeSeries({
|
|
|
- // datapoints: [[120,10],[160,20]],
|
|
|
- // alias: 'series1',
|
|
|
- // });
|
|
|
- // });
|
|
|
- //
|
|
|
- // it('should set min to 100 and max to 200', function() {
|
|
|
- // expect(ctx.plotOptions.yaxes[0].min).to.be(100);
|
|
|
- // expect(ctx.plotOptions.yaxes[0].max).to.be(200);
|
|
|
- // });
|
|
|
- // });
|
|
|
- // describe('and Y-Min is 0 and Y-Max is 0', function() {
|
|
|
- // ctx.setup(function(ctrl, data) {
|
|
|
- // ctrl.panel.yaxes[0].min = '0';
|
|
|
- // ctrl.panel.yaxes[0].max = '0';
|
|
|
- // data[0] = new TimeSeries({
|
|
|
- // datapoints: [[120,10],[160,20]],
|
|
|
- // alias: 'series1',
|
|
|
- // });
|
|
|
- // });
|
|
|
- //
|
|
|
- // it('should set min to 0 and max to 0', function() {
|
|
|
- // expect(ctx.plotOptions.yaxes[0].min).to.be(0);
|
|
|
- // expect(ctx.plotOptions.yaxes[0].max).to.be(0);
|
|
|
- // });
|
|
|
- // });
|
|
|
- // describe('and negative values used', function() {
|
|
|
- // ctx.setup(function(ctrl, data) {
|
|
|
- // ctrl.panel.yaxes[0].min = '-10';
|
|
|
- // ctrl.panel.yaxes[0].max = '-13.14';
|
|
|
- // data[0] = new TimeSeries({
|
|
|
- // datapoints: [[120,10],[160,20]],
|
|
|
- // alias: 'series1',
|
|
|
- // });
|
|
|
- // });
|
|
|
- //
|
|
|
- // it('should set min and max to negative', function() {
|
|
|
- // expect(ctx.plotOptions.yaxes[0].min).to.be(-10);
|
|
|
- // expect(ctx.plotOptions.yaxes[0].max).to.be(-13.14);
|
|
|
- // });
|
|
|
- // });
|
|
|
- // });
|
|
|
- // graphScenario('when using Y-Min and Y-Max settings stored as number', function(ctx) {
|
|
|
- // describe('and Y-Min is 0 and Y-Max is 100', function() {
|
|
|
- // ctx.setup(function(ctrl, data) {
|
|
|
- // ctrl.panel.yaxes[0].min = 0;
|
|
|
- // ctrl.panel.yaxes[0].max = 100;
|
|
|
- // data[0] = new TimeSeries({
|
|
|
- // datapoints: [[120,10],[160,20]],
|
|
|
- // alias: 'series1',
|
|
|
- // });
|
|
|
- // });
|
|
|
- //
|
|
|
- // it('should set min to 0 and max to 100', function() {
|
|
|
- // expect(ctx.plotOptions.yaxes[0].min).to.be(0);
|
|
|
- // expect(ctx.plotOptions.yaxes[0].max).to.be(100);
|
|
|
- // });
|
|
|
- // });
|
|
|
- // describe('and Y-Min is -100 and Y-Max is -10.5', function() {
|
|
|
- // ctx.setup(function(ctrl, data) {
|
|
|
- // ctrl.panel.yaxes[0].min = -100;
|
|
|
- // ctrl.panel.yaxes[0].max = -10.5;
|
|
|
- // data[0] = new TimeSeries({
|
|
|
- // datapoints: [[120,10],[160,20]],
|
|
|
- // alias: 'series1',
|
|
|
- // });
|
|
|
- // });
|
|
|
- //
|
|
|
- // it('should set min to -100 and max to -10.5', function() {
|
|
|
- // expect(ctx.plotOptions.yaxes[0].min).to.be(-100);
|
|
|
- // expect(ctx.plotOptions.yaxes[0].max).to.be(-10.5);
|
|
|
- // });
|
|
|
- // });
|
|
|
- // });
|
|
|
});
|