diff --git a/src/plot_api/helpers.js b/src/plot_api/helpers.js index 8a49ae911ae..efff787be25 100644 --- a/src/plot_api/helpers.js +++ b/src/plot_api/helpers.js @@ -18,6 +18,7 @@ var Plots = require('../plots/plots'); var AxisIds = require('../plots/cartesian/axis_ids'); var cleanId = AxisIds.cleanId; var getFromTrace = AxisIds.getFromTrace; +var id2name = AxisIds.id2name; var Color = require('../components/color'); @@ -570,25 +571,35 @@ exports.hasParent = function(aobj, attr) { * @param {object} layoutUpdate: any update being done concurrently to the layout, * which may supercede clearing the axis types */ -var axLetters = ['x', 'y', 'z']; +var xy = ['x', 'y']; +var xyz = ['x', 'y', 'z']; exports.clearAxisTypes = function(gd, traces, layoutUpdate) { for(var i = 0; i < traces.length; i++) { var trace = gd._fullData[i]; - for(var j = 0; j < 3; j++) { - var ax = getFromTrace(gd, trace, axLetters[j]); - - // do not clear log type - that's never an auto result so must have been intentional - if(ax && ax.type !== 'log') { - var axAttr = ax._name; - var sceneName = ax._id.substr(1); - if(sceneName.substr(0, 5) === 'scene') { - if(layoutUpdate[sceneName] !== undefined) continue; - axAttr = sceneName + '.' + axAttr; - } - var typeAttr = axAttr + '.type'; - - if(layoutUpdate[axAttr] === undefined && layoutUpdate[typeAttr] === undefined) { - Lib.nestedProperty(gd.layout, typeAttr).set(null); + var letters = Registry.traceIs(trace, 'gl3d') ? xyz : xy; + + for(var j = 0; j < letters.length; j++) { + var l = letters[j]; + var axes = trace.type === 'splom' ? + trace[l + 'axes'].map(function(id) { return gd._fullLayout[id2name(id)]; }) : + [getFromTrace(gd, trace, l)]; + + for(var k = 0; k < axes.length; k++) { + var ax = axes[k]; + + // do not clear log type - that's never an auto result so must have been intentional + if(ax && ax.type !== 'log') { + var axAttr = ax._name; + var sceneName = ax._id.substr(1); + if(sceneName.substr(0, 5) === 'scene') { + if(layoutUpdate[sceneName] !== undefined) continue; + axAttr = sceneName + '.' + axAttr; + } + var typeAttr = axAttr + '.type'; + + if(layoutUpdate[axAttr] === undefined && layoutUpdate[typeAttr] === undefined) { + Lib.nestedProperty(gd.layout, typeAttr).set(null); + } } } } diff --git a/src/traces/splom/attributes.js b/src/traces/splom/attributes.js index 2a6aeb321de..8c261a33abf 100644 --- a/src/traces/splom/attributes.js +++ b/src/traces/splom/attributes.js @@ -125,7 +125,7 @@ module.exports = { valType: 'boolean', role: 'info', dflt: true, - editType: 'calc', + editType: 'calc+clearAxisTypes', description: [ 'Determines whether or not subplots on the diagonal are displayed.' ].join(' ') @@ -142,7 +142,7 @@ module.exports = { valType: 'boolean', role: 'info', dflt: true, - editType: 'calc', + editType: 'calc+clearAxisTypes', description: [ 'Determines whether or not subplots on the upper half', 'from the diagonal are displayed.' @@ -152,7 +152,7 @@ module.exports = { valType: 'boolean', role: 'info', dflt: true, - editType: 'calc', + editType: 'calc+clearAxisTypes', description: [ 'Determines whether or not subplots on the lower half', 'from the diagonal are displayed.' diff --git a/test/jasmine/tests/splom_test.js b/test/jasmine/tests/splom_test.js index f7561562582..4a6e0986f4f 100644 --- a/test/jasmine/tests/splom_test.js +++ b/test/jasmine/tests/splom_test.js @@ -774,6 +774,45 @@ describe('Test splom interactions:', function() { .catch(failTest) .then(done); }); + + it('@gl should clear axis auto-types when changing subplot arrangement', function(done) { + var data = [{ + type: 'splom', + showupperhalf: false, + diagonal: {visible: false}, + dimensions: [{ + values: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + }, { + values: ['lyndon', 'richard', 'gerald', 'jimmy', 'ronald', 'george', 'bill', 'georgeW', 'barack', 'donald'] + }, { + values: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + }] + }]; + + Plotly.plot(gd, data).then(function() { + expect(gd.layout.xaxis.type).toBe('linear'); + expect(gd.layout.xaxis2.type).toBe('category'); + expect(gd.layout.xaxis3).toBeUndefined(); + expect(gd.layout.yaxis.type).toBe('category'); + expect(gd.layout.yaxis2.type).toBe('linear'); + expect(gd.layout.yaxis3).toBeUndefined(); + + return Plotly.restyle(gd, { + 'showupperhalf': true, + 'diagonal.visible': true + }); + }) + .then(function() { + expect(gd.layout.xaxis.type).toBe('linear'); + expect(gd.layout.xaxis2.type).toBe('category'); + expect(gd.layout.xaxis3.type).toBe('linear'); + expect(gd.layout.yaxis.type).toBe('linear'); + expect(gd.layout.yaxis2.type).toBe('category'); + expect(gd.layout.yaxis3.type).toBe('linear'); + }) + .catch(failTest) + .then(done); + }); }); describe('Test splom update switchboard:', function() {