Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/plots/cartesian/axis_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ var setConvert = require('./set_convert');
*/
module.exports = function handleAxisDefaults(containerIn, containerOut, coerce, options, layoutOut) {
var letter = options.letter;
var id = containerOut._id;
var font = options.font || {};
var splomStash = options.splomStash || {};

var visible = coerce('visible', !options.cheateronly);

Expand Down Expand Up @@ -66,7 +66,7 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce,
// template too.
var dfltFontColor = (dfltColor !== layoutAttributes.color.dflt) ? dfltColor : font.color;
// try to get default title from splom trace, fallback to graph-wide value
var dfltTitle = ((layoutOut._splomAxes || {})[letter] || {})[id] || layoutOut._dfltTitle[letter];
var dfltTitle = splomStash.label || layoutOut._dfltTitle[letter];

coerce('title', dfltTitle);
Lib.coerceFont(coerce, 'titlefont', {
Expand Down
8 changes: 6 additions & 2 deletions src/plots/cartesian/layout_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
axLayoutOut._annIndices = [];
axLayoutOut._shapeIndices = [];

handleTypeDefaults(axLayoutIn, axLayoutOut, coerce, traces, axName);
// set up some private properties
axLayoutOut._name = axName;
var id = axLayoutOut._id = name2id(axName);

var overlayableAxes = getOverlayableAxes(axLetter, axName);

Expand All @@ -170,9 +172,11 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
bgColor: bgColor,
calendar: layoutOut.calendar,
automargin: true,
cheateronly: axLetter === 'x' && xaCheater[axName] && !xaNonCheater[axName]
cheateronly: axLetter === 'x' && xaCheater[axName] && !xaNonCheater[axName],
splomStash: ((layoutOut._splomAxes || {})[axLetter] || {})[id]
};

handleTypeDefaults(axLayoutIn, axLayoutOut, coerce, defaultOptions);
handleAxisDefaults(axLayoutIn, axLayoutOut, coerce, defaultOptions, layoutOut);

var spikecolor = coerce2('spikecolor'),
Expand Down
19 changes: 6 additions & 13 deletions src/plots/cartesian/type_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,24 @@
* LICENSE file in the root directory of this source tree.
*/


'use strict';

var Registry = require('../../registry');
var autoType = require('./axis_autotype');
var name2id = require('./axis_ids').name2id;

/*
* data: the plot data to use in choosing auto type
* name: axis object name (ie 'xaxis') if one should be stored
*/
module.exports = function handleTypeDefaults(containerIn, containerOut, coerce, data, name) {
// set up some private properties
if(name) {
containerOut._name = name;
containerOut._id = name2id(name);
}
module.exports = function handleTypeDefaults(containerIn, containerOut, coerce, options) {
var axType = coerce('type', (options.splomStash || {}).type);

var axType = coerce('type');
if(axType === '-') {
setAutoType(containerOut, data);
setAutoType(containerOut, options.data);

if(containerOut.type === '-') {
containerOut.type = 'linear';
}
else {
} else {
// copy autoType back to input axis
// note that if this object didn't exist
// in the input layout, we have to put it in
Expand Down Expand Up @@ -89,9 +81,10 @@ function setAutoType(ax, data) {
}
else if(d0.type === 'splom') {
var dimensions = d0.dimensions;
var diag = d0._diag;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recall that _diag is:

// build list of [x,y] axis corresponding to each dimensions[i],
// very useful for passing options to regl-splom
var diag = traceOut._diag = new Array(dimLength);
// cases where showDiag and showLower or showUpper are false
// no special treatment as the xaxes and yaxes items no longer match
// the dimensions items 1-to-1
var xShift = !showDiag && !showLower ? -1 : 0;
var yShift = !showDiag && !showUpper ? -1 : 0;
for(i = 0; i < dimLength; i++) {
var dim = dimensions[i];
var xa = xaxes[i + xShift];
var ya = yaxes[i + yShift];
fillAxisStash(layout, xa, dim);
fillAxisStash(layout, ya, dim);
// note that some the entries here may be undefined
diag[i] = [xa, ya];
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok - a little confusing as usually xa is a full axis object, an id would be xId or something... but anyway nice fix!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cleaned up in -> f3c73db

for(i = 0; i < dimensions.length; i++) {
var dim = dimensions[i];
if(dim.visible) {
if(dim.visible && (diag[i][0] === id || diag[i][1] === id)) {
ax.type = autoType(dim.values, calendar);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/plots/gl3d/layout/axis_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, options) {
containerOut._id = axName[0] + options.scene;
containerOut._name = axName;

handleTypeDefaults(containerIn, containerOut, coerce, options.data);
handleTypeDefaults(containerIn, containerOut, coerce, options);

handleAxisDefaults(
containerIn,
Expand Down
17 changes: 17 additions & 0 deletions src/traces/splom/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,23 @@ module.exports = {
description: 'Sets the dimension values to be plotted.'
},

axis: {
type: {
valType: 'enumerated',
values: ['linear', 'log', 'date', 'category'],
role: 'info',
editType: 'calc+clearAxisTypes',
description: [
'Sets the axis type for this dimension\'s generated',
'x and y axes.',
'Note that the axis `type` values set in layout take',
'precedence over this attribute.'
].join(' ')
},

editType: 'calc+clearAxisTypes'
},

// TODO should add an attribute to pin down x only vars and y only vars
// like https://seaborn.pydata.org/generated/seaborn.pairplot.html
// x_vars and y_vars
Expand Down
36 changes: 17 additions & 19 deletions src/traces/splom/base_plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,36 +45,34 @@ function drag(gd) {
for(var i = 0; i < cd.length; i++) {
var cd0 = cd[i][0];
var trace = cd0.trace;
var scene = cd0.t._scene;
var stash = cd0.t;
var scene = stash._scene;

if(trace.type === 'splom' && scene && scene.matrix) {
dragOne(gd, trace, scene);
dragOne(gd, trace, stash, scene);
}
}
}

function dragOne(gd, trace, scene) {
var dimensions = trace.dimensions;
function dragOne(gd, trace, stash, scene) {
var visibleLength = scene.matrixOptions.data.length;
var visibleDims = stash.visibleDims;
var ranges = new Array(visibleLength);

for(var i = 0, k = 0; i < dimensions.length; i++) {
if(dimensions[i].visible) {
var rng = ranges[k] = new Array(4);
for(var k = 0; k < visibleDims.length; k++) {
var i = visibleDims[k];
var rng = ranges[k] = new Array(4);

var xa = AxisIDs.getFromId(gd, trace._diag[i][0]);
if(xa) {
rng[0] = xa.r2l(xa.range[0]);
rng[2] = xa.r2l(xa.range[1]);
}

var ya = AxisIDs.getFromId(gd, trace._diag[i][1]);
if(ya) {
rng[1] = ya.r2l(ya.range[0]);
rng[3] = ya.r2l(ya.range[1]);
}
var xa = AxisIDs.getFromId(gd, trace._diag[i][0]);
if(xa) {
rng[0] = xa.r2l(xa.range[0]);
rng[2] = xa.r2l(xa.range[1]);
}

k++;
var ya = AxisIDs.getFromId(gd, trace._diag[i][1]);
if(ya) {
rng[1] = ya.r2l(ya.range[0]);
rng[3] = ya.r2l(ya.range[1]);
}
}

Expand Down
20 changes: 14 additions & 6 deletions src/traces/splom/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ function dimensionDefaults(dimIn, dimOut) {

if(!(values && values.length)) dimOut.visible = false;
else coerce('visible');

coerce('axis.type');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. I committed the new lines in splom/attributes.js in 9039a8e by accident. My bad.

}

function handleAxisDefaults(traceIn, traceOut, layout, coerce) {
Expand Down Expand Up @@ -113,14 +115,14 @@ function handleAxisDefaults(traceIn, traceOut, layout, coerce) {

for(i = 0; i < dimLength; i++) {
var dim = dimensions[i];
var xa = xaxes[i + xShift];
var ya = yaxes[i + yShift];
var xaId = xaxes[i + xShift];
var yaId = yaxes[i + yShift];

fillAxisStash(layout, xa, dim);
fillAxisStash(layout, ya, dim);
fillAxisStash(layout, xaId, dim);
fillAxisStash(layout, yaId, dim);

// note that some the entries here may be undefined
diag[i] = [xa, ya];
diag[i] = [xaId, yaId];
}

// when lower half is omitted, override grid default
Expand Down Expand Up @@ -148,7 +150,13 @@ function fillAxisStash(layout, axId, dim) {
var stash = layout._splomAxes[axLetter];

if(!(axId in stash)) {
stash[axId] = (dim || {}).label || '';
var s = stash[axId] = {};
if(dim) {
s.label = dim.label || '';
if(dim.visible && dim.axis) {
s.type = dim.axis.type;
}
}
}
}

Expand Down
Loading