diff --git a/src/plots/domain.js b/src/plots/domain.js index 343e0c451e4..abdfbd84a33 100644 --- a/src/plots/domain.js +++ b/src/plots/domain.js @@ -127,6 +127,10 @@ exports.defaults = function(containerOut, layout, coerce, dfltDomains) { } } - coerce('domain.x', dfltX); - coerce('domain.y', dfltY); + var x = coerce('domain.x', dfltX); + var y = coerce('domain.y', dfltY); + + // don't accept bad input data + if(!(x[0] < x[1])) containerOut.domain.x = dfltX.slice(); + if(!(y[0] < y[1])) containerOut.domain.y = dfltY.slice(); }; diff --git a/test/jasmine/tests/plots_test.js b/test/jasmine/tests/plots_test.js index 2b6e777ae62..443cdb9ad3e 100644 --- a/test/jasmine/tests/plots_test.js +++ b/test/jasmine/tests/plots_test.js @@ -13,6 +13,27 @@ describe('Test Plots', function() { 'use strict'; describe('Plots.supplyDefaults', function() { + it('should not accept ranges where the end is not greater than the start', function() { + var gd = { + data: [{ + type: 'pie', + domain: { + x: [0.4, 0], + y: [0.5, 0.5] + }, + values: [1, 2, 3, 4], + labels: ['a', 'b', 'c', 'd'], + text: ['text', 'should', 'be', 'inside'] + }] + }; + + supplyAllDefaults(gd); + expect(gd._fullData[0].domain.x[0]).toBe(0); + expect(gd._fullData[0].domain.y[1]).toBe(1); + expect(gd._fullData[0].domain.x[0]).toBe(0); + expect(gd._fullData[0].domain.y[1]).toBe(1); + }); + it('should not throw an error when gd is a plain object', function() { var height = 100; var gd = {