Skip to content

reduce plot api imports #3819

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 2 commits into from
May 8, 2019
Merged
Changes from all 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
21 changes: 12 additions & 9 deletions src/plot_api/plot_schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ var editTypes = require('./edit_types');
var extendFlat = Lib.extendFlat;
var extendDeepAll = Lib.extendDeepAll;
var isPlainObject = Lib.isPlainObject;
var isArrayOrTypedArray = Lib.isArrayOrTypedArray;
var nestedProperty = Lib.nestedProperty;
var valObjectMeta = Lib.valObjectMeta;

var IS_SUBPLOT_OBJ = '_isSubplotObj';
var IS_LINKED_TO_ARRAY = '_isLinkedToArray';
Expand Down Expand Up @@ -65,7 +68,7 @@ exports.get = function() {

return {
defs: {
valObjects: Lib.valObjectMeta,
valObjects: valObjectMeta,
metaKeys: UNDERSCORE_ATTRS.concat(['description', 'role', 'editType', 'impliedEdits']),
editType: {
traces: editTypes.traces,
Expand Down Expand Up @@ -204,19 +207,19 @@ exports.findArrayAttributes = function(trace) {
var item = container[stack[i]];
var newAstrPartial = astrPartial + stack[i];
if(i === stack.length - 1) {
if(Lib.isArrayOrTypedArray(item)) {
if(isArrayOrTypedArray(item)) {
arrayAttributes.push(baseAttrName + newAstrPartial);
}
} else {
if(isArrayStack[i]) {
if(Array.isArray(item)) {
for(var j = 0; j < item.length; j++) {
if(Lib.isPlainObject(item[j])) {
if(isPlainObject(item[j])) {
crawlIntoTrace(item[j], i + 1, newAstrPartial + '[' + j + '].');
}
}
}
} else if(Lib.isPlainObject(item)) {
} else if(isPlainObject(item)) {
crawlIntoTrace(item, i + 1, newAstrPartial + '.');
}
}
Expand Down Expand Up @@ -463,9 +466,9 @@ function getTraceAttributes(type) {

// prune global-level trace attributes that are already defined in a trace
exports.crawl(copyModuleAttributes, function(attr, attrName, attrs, level, fullAttrString) {
Lib.nestedProperty(copyBaseAttributes, fullAttrString).set(undefined);
nestedProperty(copyBaseAttributes, fullAttrString).set(undefined);
// Prune undefined attributes
if(attr === undefined) Lib.nestedProperty(copyModuleAttributes, fullAttrString).set(undefined);
if(attr === undefined) nestedProperty(copyModuleAttributes, fullAttrString).set(undefined);
});

// base attributes (same for all trace types)
Expand Down Expand Up @@ -597,7 +600,7 @@ function getTransformAttributes(type) {

function getFramesAttributes() {
var attrs = {
frames: Lib.extendDeepAll({}, frameAttributes)
frames: extendDeepAll({}, frameAttributes)
};

formatAttributes(attrs);
Expand Down Expand Up @@ -699,15 +702,15 @@ function assignPolarLayoutAttrs(layoutAttributes) {
}

function handleBasePlotModule(layoutAttributes, _module, astr) {
var np = Lib.nestedProperty(layoutAttributes, astr);
var np = nestedProperty(layoutAttributes, astr);
var attrs = extendDeepAll({}, _module.layoutAttributes);

attrs[IS_SUBPLOT_OBJ] = true;
np.set(attrs);
}

function insertAttrs(baseAttrs, newAttrs, astr) {
var np = Lib.nestedProperty(baseAttrs, astr);
var np = nestedProperty(baseAttrs, astr);

np.set(extendDeepAll(np.get() || {}, newAttrs));
}