Skip to content

Make frame with nulls clear items & array containers #1118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Nov 11, 2016
Merged
5 changes: 3 additions & 2 deletions src/components/annotations/annotation_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ var Axes = require('../../plots/cartesian/axes');
var attributes = require('./attributes');


module.exports = function handleAnnotationDefaults(annIn, annOut, fullLayout, opts) {
module.exports = function handleAnnotationDefaults(annIn, annOut, fullLayout, opts, itemOpts) {
opts = opts || {};
itemOpts = itemOpts || {};

function coerce(attr, dflt) {
return Lib.coerce(annIn, annOut, attributes, attr, dflt);
}

var visible = coerce('visible', !opts.itemIsNotPlainObject);
var visible = coerce('visible', !itemOpts.itemIsNotPlainObject);

if(!visible) return annOut;

Expand Down
5 changes: 3 additions & 2 deletions src/components/shapes/shape_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ var attributes = require('./attributes');
var helpers = require('./helpers');


module.exports = function handleShapeDefaults(shapeIn, shapeOut, fullLayout, opts) {
module.exports = function handleShapeDefaults(shapeIn, shapeOut, fullLayout, opts, itemOpts) {
opts = opts || {};
itemOpts = itemOpts || {};

function coerce(attr, dflt) {
return Lib.coerce(shapeIn, shapeOut, attributes, attr, dflt);
}

var visible = coerce('visible', !opts.itemIsNotPlainObject);
var visible = coerce('visible', !itemOpts.itemIsNotPlainObject);

if(!visible) return shapeOut;

Expand Down
22 changes: 12 additions & 10 deletions src/plots/array_container_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,20 @@ var Lib = require('../lib');
* - name {string}
* name of the key linking the container in question
* - handleItemDefaults {function}
* defaults method to be called on each item in the array container in question,
* defaults method to be called on each item in the array container in question
*
* Its arguments are:
* - itemIn {object} item in user layout
* - itemOut {object} item in full layout
* - parentObj {object} (as in closure)
* - opts {object} (as in closure)
* - itemOpts {object}
* - itemIsNotPlainObject {boolean}
* N.B.
*
* - opts is passed to handleItemDefaults so it can also store
* links to supplementary data (e.g. fullData for layout components)
*
* - opts.itemIsNotPlainObject is mutated on every pass in case so logic
* in handleItemDefaults relies on that fact.
*
*/
module.exports = function handleArrayContainerDefaults(parentObjIn, parentObjOut, opts) {
Copy link
Contributor Author

@etpinard etpinard Nov 10, 2016

Choose a reason for hiding this comment

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

similar to plots/subplot_defaults.

The logic below is pretty trivial, but might as well 🔒 down the behavior for all array containers.

var name = opts.name;
Expand All @@ -45,17 +49,15 @@ module.exports = function handleArrayContainerDefaults(parentObjIn, parentObjOut

for(var i = 0; i < contIn.length; i++) {
var itemIn = contIn[i],
itemOut = {};
itemOut = {},
itemOpts = {};

if(!Lib.isPlainObject(itemIn)) {
opts.itemIsNotPlainObject = true;
itemOpts.itemIsNotPlainObject = true;
itemIn = {};
}
else {
opts.itemIsNotPlainObject = false;
}

opts.handleItemDefaults(itemIn, itemOut, parentObjOut, opts);
opts.handleItemDefaults(itemIn, itemOut, parentObjOut, opts, itemOpts);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sure, that's fine. I still don't quite see where the handler will use the original opts but I guess it doesn't hurt to leave it in.


itemOut._input = itemIn;
itemOut._index = i;
Expand Down