diff --git a/src/kibana/components/timepicker/timepicker.js b/src/kibana/components/timepicker/timepicker.js index 71ad587c174bae..cb7552f6075b1d 100644 --- a/src/kibana/components/timepicker/timepicker.js +++ b/src/kibana/components/timepicker/timepicker.js @@ -6,7 +6,7 @@ define(function (require) { var moment = require('moment'); require('directives/input_datetime'); - require('directives/greater_than'); + require('directives/inequality'); require('components/timepicker/quick_ranges'); require('components/timepicker/refresh_intervals'); require('components/timepicker/time_units'); diff --git a/src/kibana/components/vis/vis.js b/src/kibana/components/vis/vis.js index c8d8fd1e5c7521..6f959ce926d5e1 100644 --- a/src/kibana/components/vis/vis.js +++ b/src/kibana/components/vis/vis.js @@ -70,7 +70,7 @@ define(function (require) { if (_.isString(this.type)) this.type = visTypes.byName[this.type]; this.listeners = _.assign({}, state.listeners, this.type.listeners); - this.params = _.defaults({}, state.params || {}, this.type.params.defaults || {}); + this.params = _.defaults({}, _.cloneDeep(state.params || {}), this.type.params.defaults || {}); this.aggs = new AggConfigs(this, state.aggs); }; diff --git a/src/kibana/components/vislib/lib/handler/types/point_series.js b/src/kibana/components/vislib/lib/handler/types/point_series.js index 82d806d9c3bd28..70b7a774bbcb8c 100644 --- a/src/kibana/components/vislib/lib/handler/types/point_series.js +++ b/src/kibana/components/vislib/lib/handler/types/point_series.js @@ -18,7 +18,9 @@ define(function (require) { opts = opts || {}; return function (vis) { + var isUserDefinedYAxis = vis._attr.setYExtents; var data; + if (opts.zeroFill) { data = new Data(injectZeros(vis.data), vis._attr); } else { @@ -41,12 +43,13 @@ define(function (require) { alerts: new Alerts(vis, data, opts.alerts), yAxis: new YAxis({ el : vis.el, - yMin : data.getYMin(), - yMax : data.getYMax(), - _attr: vis._attr, - yAxisFormatter: data.get('yAxisFormatter') + yMin : isUserDefinedYAxis ? vis._attr.yAxis.min : data.getYMin(), + yMax : isUserDefinedYAxis ? vis._attr.yAxis.max : data.getYMax(), + yAxisFormatter: data.get('yAxisFormatter'), + _attr: vis._attr }) }); + }; } @@ -79,4 +82,3 @@ define(function (require) { }; }; }); - diff --git a/src/kibana/components/vislib/lib/y_axis.js b/src/kibana/components/vislib/lib/y_axis.js index f3f819f272ad1a..d2e69a5eca28b0 100644 --- a/src/kibana/components/vislib/lib/y_axis.js +++ b/src/kibana/components/vislib/lib/y_axis.js @@ -15,8 +15,8 @@ define(function (require) { */ function YAxis(args) { this.el = args.el; - this.yMin = args.yMin; - this.yMax = args.yMax; + this.scale = null; + this.domain = [args.yMin, args.yMax]; this.yAxisFormatter = args.yAxisFormatter; this._attr = args._attr || {}; } @@ -33,16 +33,46 @@ define(function (require) { d3.select(this.el).selectAll('.y-axis-div').call(this.draw()); }; - YAxis.prototype.throwCustomError = function (message) { - throw new Error(message); + YAxis.prototype._isPercentage = function () { + return (this._attr.mode === 'percentage'); }; - YAxis.prototype.throwCannotLogScaleNegVals = function () { - throw new errors.CannotLogScaleNegVals(); + YAxis.prototype._isUserDefined = function () { + return (this._attr.setYExtents); + }; + + YAxis.prototype._isYExtents = function () { + return (this._attr.defaultYExtents); + }; + + YAxis.prototype._validateUserExtents = function (domain) { + var self = this; + + return domain.map(function (val) { + val = parseInt(val, 10); + + if (isNaN(val)) throw new Error(val + ' is not a valid number'); + if (self._isPercentage() && self._attr.setYExtents) return val / 100; + return val; + }); + }; + + YAxis.prototype._getExtents = function (domain) { + var min = domain[0]; + var max = domain[1]; + + if (this._attr.scale === 'log') return this._logDomain(min, max); // Negative values cannot be displayed with a log scale. + if (!this._isYExtents() && !this._isUserDefined()) return [Math.min(0, min), Math.max(0, max)]; + if (this._isUserDefined()) return this._validateUserExtents(domain); + return domain; + }; + + YAxis.prototype._throwCustomError = function (message) { + throw new Error(message); }; - YAxis.prototype.throwNoResultsError = function () { - throw new errors.NoResults(); + YAxis.prototype._throwCannotLogScaleNegVals = function () { + throw new errors.CannotLogScaleNegVals(); }; /** @@ -51,11 +81,11 @@ define(function (require) { * @param fnName {String} D3 scale * @returns {*} */ - YAxis.prototype.getScaleType = function (fnName) { + YAxis.prototype._getScaleType = function (fnName) { if (fnName === 'square root') fnName = 'sqrt'; // Rename 'square root' to 'sqrt' fnName = fnName || 'linear'; - if (typeof d3.scale[fnName] !== 'function') return this.throwCustomError('YAxis.getScaleType: ' + fnName + ' is not a function'); + if (typeof d3.scale[fnName] !== 'function') return this._throwCustomError('YAxis.getScaleType: ' + fnName + ' is not a function'); return d3.scale[fnName](); }; @@ -69,29 +99,9 @@ define(function (require) { * @param yMax * @returns {*[]} */ - YAxis.prototype.returnLogDomain = function (yMin, yMax) { - if (yMin < 0 || yMax < 0) return this.throwCannotLogScaleNegVals(); - return [Math.max(1, yMin), yMax]; - }; - - YAxis.prototype._setDefaultYExtents = function () { - return this._attr.defaultYExtents; - }; - - /** - * Returns the domain, i.e. the extent of the y axis - * - * @param scale {String} Kibana scale - * @param yMin {Number} Y-axis minimum value - * @param yMax {Number} Y-axis maximum value - * @returns {*[]} - */ - YAxis.prototype.getDomain = function (scale, yMin, yMax) { - if (this._setDefaultYExtents()) return [yMin, yMax]; - if (scale === 'log') return this.returnLogDomain(yMin, yMax); // Negative values cannot be displayed with a log scale. - if (yMin === 0 && yMax === 0) return this.throwNoResultsError(); // yMin and yMax can never both be equal to zero - - return [Math.min(0, yMin), Math.max(0, yMax)]; + YAxis.prototype._logDomain = function (min, max) { + if (min < 0 || max < 0) return this._throwCannotLogScaleNegVals(); + return [Math.max(1, min), max]; }; /** @@ -102,14 +112,16 @@ define(function (require) { * @returns {D3.Scale.QuantitiveScale|*} D3 yScale function */ YAxis.prototype.getYScale = function (height) { - this.yScale = this.getScaleType(this._attr.scale) - .domain(this.getDomain(this._attr.scale, this.yMin, this.yMax)) + var scale = this._getScaleType(this._attr.scale); + var domain = this._getExtents(this.domain); + + this.yScale = scale + .domain(domain) .range([height, 0]); - // Nicing the scale, rounds values down or up to make the scale look better - // When defaultYExtents are selected, the extents (i.e. min and max) should - // be shown without any rounding. - if (!this._attr.defaultYExtents) return this.yScale.nice(); + if (!this._isUserDefined()) this.yScale.nice(); // round extents when not user defined + // Prevents bars from going off the chart when the y extents are within the domain range + if (this._attr.type === 'histogram') this.yScale.clamp(true); return this.yScale; }; @@ -120,6 +132,10 @@ define(function (require) { return d3.format('n'); }; + YAxis.prototype._validateYScale = function (yScale) { + if (!yScale || _.isNaN(yScale)) throw new Error('yScale is ' + yScale); + }; + /** * Creates the d3 y axis function * @@ -129,16 +145,12 @@ define(function (require) { */ YAxis.prototype.getYAxis = function (height) { var yScale = this.getYScale(height); - - // y scale should never be `NaN` - if (!yScale || _.isNaN(yScale)) { - throw new Error('yScale is ' + yScale); - } + this._validateYScale(yScale); // Create the d3 yAxis function this.yAxis = d3.svg.axis() .scale(yScale) - .tickFormat(this.tickFormat()) + .tickFormat(this.tickFormat(this.domain)) .ticks(this.tickScale(height)) .orient('left'); @@ -177,7 +189,6 @@ define(function (require) { var isWiggleOrSilhouette = (mode === 'wiggle' || mode === 'silhouette'); return function (selection) { - selection.each(function () { var el = this; diff --git a/src/kibana/directives/greater_than.js b/src/kibana/directives/greater_than.js deleted file mode 100644 index f446b4ef5d636b..00000000000000 --- a/src/kibana/directives/greater_than.js +++ /dev/null @@ -1,21 +0,0 @@ -define(function (require) { - require('modules') - .get('kibana') - .directive('greaterThan', function () { - return { - require: 'ngModel', - link: function ($scope, $el, $attr, ngModel) { - var val = $attr.greaterThan || 0; - ngModel.$parsers.push(validator); - ngModel.$formatters.push(validator); - - function validator(value) { - var valid = false; - if (!isNaN(value)) valid = value > val; - ngModel.$setValidity('greaterThan', valid); - return value; - } - } - }; - }); -}); \ No newline at end of file diff --git a/src/kibana/directives/inequality.js b/src/kibana/directives/inequality.js new file mode 100644 index 00000000000000..fe1f5b3230e91f --- /dev/null +++ b/src/kibana/directives/inequality.js @@ -0,0 +1,40 @@ +define(function (require) { + + function makeDirectiveDef(id, compare) { + return function ($parse) { + return { + require: 'ngModel', + link: function ($scope, $el, $attr, ngModel) { + var getBound = function () { return $parse($attr[id])(); }; + var defaultVal = { + 'greaterThan': -Infinity, + 'lessThan': Infinity + }[id]; + + ngModel.$parsers.push(validate); + ngModel.$formatters.push(validate); + + $scope.$watch(getBound, function () { + validate(ngModel.$viewValue); + }); + + function validate(val) { + var bound = !isNaN(getBound()) ? +getBound() : defaultVal; + var valid = !isNaN(bound) && !isNaN(val) && compare(val, bound); + ngModel.$setValidity(id, valid); + return val; + } + } + }; + }; + } + + require('modules') + .get('kibana') + .directive('greaterThan', makeDirectiveDef('greaterThan', function (a, b) { + return a > b; + })) + .directive('lessThan', makeDirectiveDef('lessThan', function (a, b) { + return a < b; + })); +}); diff --git a/src/kibana/plugins/vis_types/controls/point_series_options.html b/src/kibana/plugins/vis_types/controls/point_series_options.html index c39a46f99e432b..e20c168f983bbf 100644 --- a/src/kibana/plugins/vis_types/controls/point_series_options.html +++ b/src/kibana/plugins/vis_types/controls/point_series_options.html @@ -1,14 +1,49 @@
-
+
-
+
+
+ +
+ Min must not exceed max +
+ +
+
+ Min must exceed 0 when a log scale is selected +
+
+ +
diff --git a/src/kibana/plugins/vis_types/controls/point_series_options.js b/src/kibana/plugins/vis_types/controls/point_series_options.js index ab3d681cc11a45..afb74b33858016 100644 --- a/src/kibana/plugins/vis_types/controls/point_series_options.js +++ b/src/kibana/plugins/vis_types/controls/point_series_options.js @@ -2,6 +2,7 @@ define(function (require) { var _ = require('lodash'); var $ = require('jquery'); var module = require('modules').get('kibana'); + require('directives/inequality'); module.directive('pointSeriesOptions', function ($parse, $compile) { return { diff --git a/src/kibana/plugins/vis_types/vislib/_vislib_vis_type.js b/src/kibana/plugins/vis_types/vislib/_vislib_vis_type.js index 600222fa29d849..eac3de5666078d 100644 --- a/src/kibana/plugins/vis_types/vislib/_vislib_vis_type.js +++ b/src/kibana/plugins/vis_types/vislib/_vislib_vis_type.js @@ -8,6 +8,7 @@ define(function (require) { var VislibRenderbot = Private(require('plugins/vis_types/vislib/_vislib_renderbot')); require('plugins/vis_types/controls/vislib_basic_options'); + require('plugins/vis_types/controls/point_series_options'); require('plugins/vis_types/controls/line_interpolation_option'); require('plugins/vis_types/controls/point_series_options'); diff --git a/src/kibana/plugins/vis_types/vislib/area.js b/src/kibana/plugins/vis_types/vislib/area.js index 4d73ed5dc76ee5..294aed6449024c 100644 --- a/src/kibana/plugins/vis_types/vislib/area.js +++ b/src/kibana/plugins/vis_types/vislib/area.js @@ -18,11 +18,13 @@ define(function (require) { addLegend: true, smoothLines: false, scale: 'linear', - mode: 'stacked', interpolate: 'linear', - defaultYExtents: false, + mode: 'stacked', times: [], - addTimeMarker: false + addTimeMarker: false, + defaultYExtents: false, + setYExtents: false, + yAxis: {} }, scales: ['linear', 'log', 'square root'], modes: ['stacked', 'overlap', 'percentage', 'wiggle', 'silhouette'], diff --git a/src/kibana/plugins/vis_types/vislib/editors/area.html b/src/kibana/plugins/vis_types/vislib/editors/area.html index bedb688ff36710..d19d6aa99953b7 100644 --- a/src/kibana/plugins/vis_types/vislib/editors/area.html +++ b/src/kibana/plugins/vis_types/vislib/editors/area.html @@ -7,5 +7,5 @@
- + diff --git a/src/kibana/plugins/vis_types/vislib/editors/histogram.html b/src/kibana/plugins/vis_types/vislib/editors/histogram.html index 8c4da8f5dc1d50..6f8ed41de7a110 100644 --- a/src/kibana/plugins/vis_types/vislib/editors/histogram.html +++ b/src/kibana/plugins/vis_types/vislib/editors/histogram.html @@ -5,5 +5,5 @@
- + diff --git a/src/kibana/plugins/vis_types/vislib/editors/line.html b/src/kibana/plugins/vis_types/vislib/editors/line.html index 69e3fead7124a1..d15895327efc6d 100644 --- a/src/kibana/plugins/vis_types/vislib/editors/line.html +++ b/src/kibana/plugins/vis_types/vislib/editors/line.html @@ -19,5 +19,5 @@ - + diff --git a/src/kibana/plugins/vis_types/vislib/histogram.js b/src/kibana/plugins/vis_types/vislib/histogram.js index 4d2152809d783e..170980a52695d1 100644 --- a/src/kibana/plugins/vis_types/vislib/histogram.js +++ b/src/kibana/plugins/vis_types/vislib/histogram.js @@ -16,9 +16,11 @@ define(function (require) { addLegend: true, scale: 'linear', mode: 'stacked', - defaultYExtents: false, times: [], - addTimeMarker: false + addTimeMarker: false, + defaultYExtents: false, + setYExtents: false, + yAxis: {} }, scales: ['linear', 'log', 'square root'], modes: ['stacked', 'percentage', 'grouped'], diff --git a/src/kibana/plugins/vis_types/vislib/line.js b/src/kibana/plugins/vis_types/vislib/line.js index b750c1c0a561ab..2d31ad07af4fd1 100644 --- a/src/kibana/plugins/vis_types/vislib/line.js +++ b/src/kibana/plugins/vis_types/vislib/line.js @@ -17,12 +17,14 @@ define(function (require) { showCircles: true, smoothLines: false, interpolate: 'linear', + scale: 'linear', drawLinesBetweenPoints: true, radiusRatio: 9, - scale: 'linear', - defaultYExtents: false, times: [], - addTimeMarker: false + addTimeMarker: false, + defaultYExtents: false, + setYExtents: false, + yAxis: {} }, scales: ['linear', 'log', 'square root'], editor: require('text!plugins/vis_types/vislib/editors/line.html') diff --git a/test/unit/specs/directives/greater_than.js b/test/unit/specs/directives/inequality.js similarity index 87% rename from test/unit/specs/directives/greater_than.js rename to test/unit/specs/directives/inequality.js index 7e097cc06fb5de..3e4c580abf3d77 100644 --- a/test/unit/specs/directives/greater_than.js +++ b/test/unit/specs/directives/inequality.js @@ -1,6 +1,6 @@ define(function (require) { var angular = require('angular'); - require('directives/greater_than'); + require('directives/inequality'); describe('greater_than model validator directive', function () { var $compile, $rootScope; @@ -27,16 +27,16 @@ define(function (require) { expect(element.hasClass('ng-valid')).to.be.ok(); }); - it('should be invalid for 0', function () { + it('should be valid for 0', function () { $rootScope.value = '0'; $rootScope.$digest(); - expect(element.hasClass('ng-invalid')).to.be.ok(); + expect(element.hasClass('ng-valid')).to.be.ok(); }); - it('should be invalid for negatives', function () { + it('should be valid for negatives', function () { $rootScope.value = '-10'; $rootScope.$digest(); - expect(element.hasClass('ng-invalid')).to.be.ok(); + expect(element.hasClass('ng-valid')).to.be.ok(); }); }); diff --git a/test/unit/specs/vislib/fixture/_vis_fixture.js b/test/unit/specs/vislib/fixture/_vis_fixture.js index d6b7a7620606e5..db0a2a6e8aaa30 100644 --- a/test/unit/specs/vislib/fixture/_vis_fixture.js +++ b/test/unit/specs/vislib/fixture/_vis_fixture.js @@ -1,6 +1,7 @@ define(function (require) { return function VisLibFixtures(Private) { var $ = require('jquery'); + var _ = require('lodash'); return function (visLibParams) { var Vis = Private(require('components/vislib/vis')); @@ -12,12 +13,15 @@ define(function (require) { $el.width(1024); $el.height(300); - var config = visLibParams || { + var config = _.defaults(visLibParams || {}, { shareYAxis: true, addTooltip: true, addLegend: true, + defaultYExtents: false, + setYExtents: false, + yAxis: {}, type: 'histogram' - }; + }); return new Vis($el, config); }; diff --git a/test/unit/specs/vislib/lib/y_axis.js b/test/unit/specs/vislib/lib/y_axis.js index 79b1448402a0ac..0d448110778f46 100644 --- a/test/unit/specs/vislib/lib/y_axis.js +++ b/test/unit/specs/vislib/lib/y_axis.js @@ -77,7 +77,10 @@ define(function (require) { yMin: dataObj.getYMin(), yMax: dataObj.getYMax(), _attr: { - margin: { top: 0, right: 0, bottom: 0, left: 0 } + margin: { top: 0, right: 0, bottom: 0, left: 0 }, + defaultYMin: true, + setYExtents: false, + yAxis: {} } })); }; @@ -126,6 +129,7 @@ define(function (require) { describe('getYScale Method', function () { var yScale; var graphData; + var domain; var height = 50; function checkDomain(min, max) { @@ -151,6 +155,20 @@ define(function (require) { }); }); + describe('should return log values', function () { + var domain; + var extents; + + it('should return 1', function () { + yAxis._attr.scale = 'log'; + extents = [0, 400]; + domain = yAxis._getExtents(extents); + + // Log scales have a yMin value of 1 + expect(domain[0]).to.be(1); + }); + }); + describe('positive values', function () { beforeEach(function () { graphData = defaultGraphData; @@ -178,7 +196,6 @@ define(function (require) { yScale = yAxis.getYScale(height); }); - it('should have domain between min value and 0', function () { var min = _.min(_.flatten(graphData)); var max = 0; @@ -186,7 +203,6 @@ define(function (require) { expect(domain[0]).to.be.lessThan(0); checkRange(); }); - }); describe('positive and negative values', function () { @@ -199,7 +215,6 @@ define(function (require) { yScale = yAxis.getYScale(height); }); - it('should have domain between min and max values', function () { var min = _.min(_.flatten(graphData)); var max = _.max(_.flatten(graphData)); @@ -210,20 +225,60 @@ define(function (require) { }); }); - describe('should not return a nice scale when defaultYExtents is true', function () { + describe('validate user defined values', function () { beforeEach(function () { - createData(defaultGraphData); - yAxis._attr.defaultYExtents = true; - yAxis.getYAxis(height); - yAxis.render(); + yAxis._attr.mode = 'stacked'; + yAxis._attr.setYExtents = false; + yAxis._attr.yAxis = {}; }); - it('not return a nice scale', function () { - var min = _.min(_.flatten(defaultGraphData)); - var max = _.max(_.flatten(defaultGraphData)); - var domain = yAxis.yAxis.scale().domain(); - expect(domain[0]).to.be(min); - expect(domain[1]).to.be(max); + it('should throw a NaN error', function () { + var min = 'Not a number'; + var max = 12; + + expect(function () { + yAxis._validateUserExtents(min, max); + }).to.throwError(); + }); + + it('should return a decimal value', function () { + yAxis._attr.mode = 'percentage'; + yAxis._attr.setYExtents = true; + domain = []; + domain[0] = yAxis._attr.yAxis.min = 20; + domain[1] = yAxis._attr.yAxis.max = 80; + var newDomain = yAxis._validateUserExtents(domain); + + expect(newDomain[0]).to.be(domain[0] / 100); + expect(newDomain[1]).to.be(domain[1] / 100); + }); + + it('should return the user defined value', function () { + domain = [20, 50]; + var newDomain = yAxis._validateUserExtents(domain); + + expect(newDomain[0]).to.be(domain[0]); + expect(newDomain[1]).to.be(domain[1]); + }); + }); + + describe('should throw an error when', function () { + it('min === max', function () { + var min = 12; + var max = 12; + + expect(function () { + yAxis._validateAxisExtents(min, max); + }).to.throwError(); + }); + + it('min > max', function () { + var min = 30; + var max = 10; + + expect(function () { + yAxis._validateAxisExtents(min, max); + }).to.throwError(); }); }); }); @@ -233,105 +288,39 @@ define(function (require) { it('should return a function', function () { fnNames.forEach(function (fnName) { - var isFunction = (typeof yAxis.getScaleType(fnName) === 'function'); - expect(isFunction).to.be(true); + expect(yAxis._getScaleType(fnName)).to.be.a(Function); }); // if no value is provided to the function, scale should default to a linear scale - expect(typeof yAxis.getScaleType()).to.be('function'); + expect(yAxis._getScaleType()).to.be.a(Function); }); it('should throw an error if function name is undefined', function () { expect(function () { - yAxis.getScaleType('square'); + yAxis._getScaleType('square'); }).to.throwError(); }); }); - describe('returnLogDomain method', function () { + describe('_logDomain method', function () { it('should throw an error', function () { expect(function () { - yAxis.returnLogDomain(-10, -5); + yAxis._logDomain(-10, -5); }).to.throwError(); expect(function () { - yAxis.returnLogDomain(-10, 5); + yAxis._logDomain(-10, 5); }).to.throwError(); expect(function () { - yAxis.returnLogDomain(0, -5); + yAxis._logDomain(0, -5); }).to.throwError(); }); it('should return a yMin value of 1', function () { - var yMin = yAxis.returnLogDomain(0, 200)[0]; + var yMin = yAxis._logDomain(0, 200)[0]; expect(yMin).to.be(1); }); }); - describe('getDomain method', function () { - beforeEach(function () { - // Need to set this to false before each test since its - // status changes in one of the tests below. Having this set to - // true causes other tests to fail that need this attr to be set to false. - yAxis._attr.defaultYExtents = false; - }); - - it('should return a log domain', function () { - var scale = 'log'; - var yMin = 0; - var yMax = 400; - var domain = yAxis.getDomain(scale, yMin, yMax); - - // Log scales have a yMin value of 1 - expect(domain[0]).to.be(1); - }); - - it('should return the default y axis extents (i.e. the min and max values)', function () { - var scale = 'linear'; - var yMin = 25; - var yMax = 150; - var domain; - - yAxis._attr.defaultYExtents = true; - domain = yAxis.getDomain(scale, yMin, yMax); - - expect(domain[0]).to.be(yMin); - expect(domain[1]).to.be(yMax); - }); - - it('should throw a no results error if yMin and yMax values are both 0', function () { - expect(function () { - yAxis.getDomain('linear', 0, 0); - }).to.throwError(); - }); - - it('should return the correct min and max values', function () { - var extents = [ - [-5, 20], - [-30, -10], - [5, 20] - ]; - - extents.forEach(function (extent) { - var domain = yAxis.getDomain('linear', extent[0], extent[1]); - - if (extent[0] < 0 && extent[1] > 0) { - expect(domain[0]).to.be(extent[0]); - expect(domain[1]).to.be(extent[1]); - } - - if (extent[0] < 0 && extent[1] < 0) { - expect(domain[0]).to.be(extent[0]); - expect(domain[1]).to.be(0); - } - - if (extent[0] > 0 && extent[1] > 0) { - expect(domain[0]).to.be(0); - expect(domain[1]).to.be(extent[1]); - } - }); - }); - }); - describe('getYAxis method', function () { var mode, yMax, yScale; beforeEach(function () { diff --git a/test/unit/specs/vislib/visualizations/area_chart.js b/test/unit/specs/vislib/visualizations/area_chart.js index 73f64f08f2a1ec..00a6cb5d0d7fa1 100644 --- a/test/unit/specs/vislib/visualizations/area_chart.js +++ b/test/unit/specs/vislib/visualizations/area_chart.js @@ -32,8 +32,7 @@ define(function (require) { var visLibParams = { type: 'area', addLegend: true, - addTooltip: true, - defaultYExtents: false + addTooltip: true }; angular.module('AreaChartFactory', ['kibana']); @@ -228,8 +227,8 @@ define(function (require) { vis.handler.charts.forEach(function (chart) { var yAxis = chart.handler.yAxis; - expect(yAxis.yMin).to.not.be(undefined); - expect(yAxis.yMax).to.not.be(undefined); + expect(yAxis.domain[0]).to.not.be(undefined); + expect(yAxis.domain[1]).to.not.be(undefined); }); }); @@ -270,8 +269,8 @@ define(function (require) { var yAxis = chart.handler.yAxis; var yVals = [vis.handler.data.getYMin(), vis.handler.data.getYMax()]; - expect(yAxis.yMin).to.equal(yVals[0]); - expect(yAxis.yMax).to.equal(yVals[1]); + expect(yAxis.domain[0]).to.equal(yVals[0]); + expect(yAxis.domain[1]).to.equal(yVals[1]); }); }); }); diff --git a/test/unit/specs/vislib/visualizations/column_chart.js b/test/unit/specs/vislib/visualizations/column_chart.js index f8cb8916e63862..8a10a1e22e38b4 100644 --- a/test/unit/specs/vislib/visualizations/column_chart.js +++ b/test/unit/specs/vislib/visualizations/column_chart.js @@ -166,8 +166,8 @@ define(function (require) { vis.handler.charts.forEach(function (chart) { var yAxis = chart.handler.yAxis; - expect(yAxis.yMin).to.not.be(undefined); - expect(yAxis.yMax).to.not.be(undefined); + expect(yAxis.domain[0]).to.not.be(undefined); + expect(yAxis.domain[1]).to.not.be(undefined); }); }); @@ -208,8 +208,8 @@ define(function (require) { var yAxis = chart.handler.yAxis; var yVals = [vis.handler.data.getYMin(), vis.handler.data.getYMax()]; - expect(yAxis.yMin).to.equal(yVals[0]); - expect(yAxis.yMax).to.equal(yVals[1]); + expect(yAxis.domain[0]).to.equal(yVals[0]); + expect(yAxis.domain[1]).to.equal(yVals[1]); }); }); }); diff --git a/test/unit/specs/vislib/visualizations/line_chart.js b/test/unit/specs/vislib/visualizations/line_chart.js index dcc73bf4c6a403..af59953feef680 100644 --- a/test/unit/specs/vislib/visualizations/line_chart.js +++ b/test/unit/specs/vislib/visualizations/line_chart.js @@ -143,8 +143,8 @@ define(function (require) { vis.handler.charts.forEach(function (chart) { var yAxis = chart.handler.yAxis; - expect(yAxis.yMin).to.not.be(undefined); - expect(yAxis.yMax).to.not.be(undefined); + expect(yAxis.domain[0]).to.not.be(undefined); + expect(yAxis.domain[1]).to.not.be(undefined); }); }); @@ -185,8 +185,8 @@ define(function (require) { var yAxis = chart.handler.yAxis; var yVals = [vis.handler.data.getYMin(), vis.handler.data.getYMax()]; - expect(yAxis.yMin).to.equal(yVals[0]); - expect(yAxis.yMax).to.equal(yVals[1]); + expect(yAxis.domain[0]).to.equal(yVals[0]); + expect(yAxis.domain[1]).to.equal(yVals[1]); }); }); });