Skip to content

Commit

Permalink
add axis.matches boolean to splom dims
Browse files Browse the repository at this point in the history
- defaults to `false`, when set to `true`,
  the generated splom axes will match
  • Loading branch information
etpinard committed Feb 1, 2019
1 parent d9c2d4e commit c290adf
Show file tree
Hide file tree
Showing 8 changed files with 1,535 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/plots/cartesian/constraints.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ var FROM_BL = require('../../constants/alignment').FROM_BL;
exports.handleConstraintDefaults = function(containerIn, containerOut, coerce, allAxisIds, layoutOut) {
var constraintGroups = layoutOut._axisConstraintGroups;
var matchGroups = layoutOut._axisMatchGroups;
var axId = containerOut._id;
var axLetter = axId.charAt(0);
var splomStash = ((layoutOut._splomAxes || {})[axLetter] || {})[axId] || {};
var thisID = containerOut._id;
var letter = thisID.charAt(0);

Expand All @@ -36,7 +39,7 @@ exports.handleConstraintDefaults = function(containerIn, containerOut, coerce, a
}
}, 'constraintoward');

if(!containerIn.scaleanchor && !containerIn.matches) return;
if(!containerIn.scaleanchor && !containerIn.matches && !splomStash.matches) return;

var opts = getConstraintOpts(constraintGroups, thisID, allAxisIds, layoutOut);

Expand All @@ -50,7 +53,8 @@ exports.handleConstraintDefaults = function(containerIn, containerOut, coerce, a
var matches = Lib.coerce(containerIn, containerOut, {
matches: {
valType: 'enumerated',
values: opts.linkableAxes
values: opts.linkableAxes,
dflt: splomStash.matches
}
}, 'matches');

Expand Down
14 changes: 14 additions & 0 deletions src/traces/splom/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,20 @@ module.exports = {
].join(' ')
},

// TODO make 'true' the default in v2?
matches: {
valType: 'boolean',
dflt: false,
role: 'info',
editType: 'calc',
description: [
'Determines whether or not the x & y axes generated by this',
'dimension match.',
'Equivalent to setting the `matches` axis attribute in the layout',
'with the correct axis id.'
].join(' ')
},

editType: 'calc+clearAxisTypes'
},

Expand Down
10 changes: 6 additions & 4 deletions src/traces/splom/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function dimensionDefaults(dimIn, dimOut) {
else coerce('visible');

coerce('axis.type');
coerce('axis.matches');
}

function handleAxisDefaults(traceIn, traceOut, layout, coerce) {
Expand Down Expand Up @@ -97,7 +98,7 @@ function handleAxisDefaults(traceIn, traceOut, layout, coerce) {
var xList = [];
var yList = [];

function fillAxisStashes(axId, dim, list) {
function fillAxisStashes(axId, counterAxId, dim, list) {
if(!axId) return;

var axLetter = axId.charAt(0);
Expand All @@ -111,7 +112,8 @@ function handleAxisDefaults(traceIn, traceOut, layout, coerce) {
if(dim) {
s.label = dim.label || '';
if(dim.visible && dim.axis) {
s.type = dim.axis.type;
if(dim.axis.type) s.type = dim.axis.type;
if(dim.axis.matches) s.matches = counterAxId;
}
}
}
Expand All @@ -136,8 +138,8 @@ function handleAxisDefaults(traceIn, traceOut, layout, coerce) {
undefined :
yaxes[i];

fillAxisStashes(xaId, dim, xList);
fillAxisStashes(yaId, dim, yList);
fillAxisStashes(xaId, yaId, dim, xList);
fillAxisStashes(yaId, xaId, dim, yList);
diag[i] = [xaId, yaId];
}

Expand Down
Binary file added test/image/baselines/splom_iris-matching.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit c290adf

Please sign in to comment.