diff --git a/package.json b/package.json index 9553fda118e5c..07b91ec74f8b3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "timelion", - "version": "5.0.0-0.1.307", + "version": "5.0.0-0.1.308", "dependencies": { "body-parser": "^1.12.0", "boom": "^2.8.0", diff --git a/public/directives/chart/chart.js b/public/directives/chart/chart.js index 81f3003f4498e..96ff2aa23f035 100644 --- a/public/directives/chart/chart.js +++ b/public/directives/chart/chart.js @@ -69,7 +69,6 @@ app.directive('chart', function ($compile, $rootScope, timefilter, $timeout, Pri ''; } }, - yaxes: [ {}, { position: 'right' } ], colors: ['#01A4A4', '#C66', '#D0D102', '#616161', '#00A1CB', '#32742C', '#F18D05', '#113F8C', '#61AE24', '#D70060'] }; diff --git a/series_functions/__test__/yaxis.js b/series_functions/__test__/yaxis.js new file mode 100644 index 0000000000000..45d0105e3ff52 --- /dev/null +++ b/series_functions/__test__/yaxis.js @@ -0,0 +1,70 @@ +const filename = require('path').basename(__filename); +const fn = require(`../${filename}`); +const Promise = require('bluebird'); + +const _ = require('lodash'); +const expect = require('chai').expect; +const invoke = require('./helpers/invoke_series_fn.js'); + +describe(filename, () => { + + let seriesList; + beforeEach(() => { + seriesList = require('./fixtures/seriesList.js')(); + }); + + it('creates the yaxes array', () => { + expect(seriesList._global).to.equal(undefined); + return invoke(fn, [seriesList, 2]).then((r) => { + expect(r.output.list[0]._global.yaxes).to.be.an('array'); + }); + }); + + it('puts odd numbers of the left, even on the right, by default', () => { + return Promise.all([ + invoke(fn, [seriesList, 1]).then((r) => { + expect(r.output.list[0]._global.yaxes[0].position).to.equal('left'); + }), + invoke(fn, [seriesList, 2]).then((r) => { + expect(r.output.list[0]._global.yaxes[1].position).to.equal('right'); + }), + invoke(fn, [seriesList, 3]).then((r) => { + expect(r.output.list[0]._global.yaxes[2].position).to.equal('left'); + }), + ]); + }); + + it('it lets you override default positions', () => { + return Promise.all([ + invoke(fn, [seriesList, 1, null, null, 'right']).then((r) => { + expect(r.output.list[0]._global.yaxes[0].position).to.equal('right'); + }), + invoke(fn, [seriesList, 2, null, null, 'right']).then((r) => { + expect(r.output.list[0]._global.yaxes[1].position).to.equal('right'); + }), + ]); + }); + + it('sets the minimum (default: 0)', () => { + return Promise.all([ + invoke(fn, [seriesList, 1, null]).then((r) => { + expect(r.output.list[0]._global.yaxes[0].min).to.equal(0); + }), + invoke(fn, [seriesList, 2, 10]).then((r) => { + expect(r.output.list[0]._global.yaxes[1].min).to.equal(10); + }), + ]); + }); + + it('sets the max (default: no max)', () => { + return Promise.all([ + invoke(fn, [seriesList, 1, null]).then((r) => { + expect(r.output.list[0]._global.yaxes[0].max).to.equal(undefined); + }), + invoke(fn, [seriesList, 2, null, 10]).then((r) => { + expect(r.output.list[0]._global.yaxes[1].max).to.equal(10); + }), + ]); + }); + +}); diff --git a/series_functions/yaxis.js b/series_functions/yaxis.js index 41e7905b36e31..85dd5c7042f9e 100644 --- a/series_functions/yaxis.js +++ b/series_functions/yaxis.js @@ -38,7 +38,7 @@ module.exports = new Chainable('yaxis', { var yaxes = eachSeries._global.yaxes = eachSeries._global.yaxes || []; var myAxis = yaxes[yaxis - 1] = yaxes[yaxis - 1] || {}; - myAxis.position = position; + myAxis.position = position || (yaxis % 2 ? 'left' : 'right'); myAxis.min = min == null ? 0 : min; myAxis.max = max;