Skip to content

Commit 8cdf799

Browse files
authored
Merge pull request #3819 from plotly/reduce-plot-api-imports
reduce plot api imports
2 parents 8f60e83 + bc0ae2c commit 8cdf799

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/plot_api/plot_schema.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ var editTypes = require('./edit_types');
2727
var extendFlat = Lib.extendFlat;
2828
var extendDeepAll = Lib.extendDeepAll;
2929
var isPlainObject = Lib.isPlainObject;
30+
var isArrayOrTypedArray = Lib.isArrayOrTypedArray;
31+
var nestedProperty = Lib.nestedProperty;
32+
var valObjectMeta = Lib.valObjectMeta;
3033

3134
var IS_SUBPLOT_OBJ = '_isSubplotObj';
3235
var IS_LINKED_TO_ARRAY = '_isLinkedToArray';
@@ -65,7 +68,7 @@ exports.get = function() {
6568

6669
return {
6770
defs: {
68-
valObjects: Lib.valObjectMeta,
71+
valObjects: valObjectMeta,
6972
metaKeys: UNDERSCORE_ATTRS.concat(['description', 'role', 'editType', 'impliedEdits']),
7073
editType: {
7174
traces: editTypes.traces,
@@ -204,19 +207,19 @@ exports.findArrayAttributes = function(trace) {
204207
var item = container[stack[i]];
205208
var newAstrPartial = astrPartial + stack[i];
206209
if(i === stack.length - 1) {
207-
if(Lib.isArrayOrTypedArray(item)) {
210+
if(isArrayOrTypedArray(item)) {
208211
arrayAttributes.push(baseAttrName + newAstrPartial);
209212
}
210213
} else {
211214
if(isArrayStack[i]) {
212215
if(Array.isArray(item)) {
213216
for(var j = 0; j < item.length; j++) {
214-
if(Lib.isPlainObject(item[j])) {
217+
if(isPlainObject(item[j])) {
215218
crawlIntoTrace(item[j], i + 1, newAstrPartial + '[' + j + '].');
216219
}
217220
}
218221
}
219-
} else if(Lib.isPlainObject(item)) {
222+
} else if(isPlainObject(item)) {
220223
crawlIntoTrace(item, i + 1, newAstrPartial + '.');
221224
}
222225
}
@@ -463,9 +466,9 @@ function getTraceAttributes(type) {
463466

464467
// prune global-level trace attributes that are already defined in a trace
465468
exports.crawl(copyModuleAttributes, function(attr, attrName, attrs, level, fullAttrString) {
466-
Lib.nestedProperty(copyBaseAttributes, fullAttrString).set(undefined);
469+
nestedProperty(copyBaseAttributes, fullAttrString).set(undefined);
467470
// Prune undefined attributes
468-
if(attr === undefined) Lib.nestedProperty(copyModuleAttributes, fullAttrString).set(undefined);
471+
if(attr === undefined) nestedProperty(copyModuleAttributes, fullAttrString).set(undefined);
469472
});
470473

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

598601
function getFramesAttributes() {
599602
var attrs = {
600-
frames: Lib.extendDeepAll({}, frameAttributes)
603+
frames: extendDeepAll({}, frameAttributes)
601604
};
602605

603606
formatAttributes(attrs);
@@ -699,15 +702,15 @@ function assignPolarLayoutAttrs(layoutAttributes) {
699702
}
700703

701704
function handleBasePlotModule(layoutAttributes, _module, astr) {
702-
var np = Lib.nestedProperty(layoutAttributes, astr);
705+
var np = nestedProperty(layoutAttributes, astr);
703706
var attrs = extendDeepAll({}, _module.layoutAttributes);
704707

705708
attrs[IS_SUBPLOT_OBJ] = true;
706709
np.set(attrs);
707710
}
708711

709712
function insertAttrs(baseAttrs, newAttrs, astr) {
710-
var np = Lib.nestedProperty(baseAttrs, astr);
713+
var np = nestedProperty(baseAttrs, astr);
711714

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

0 commit comments

Comments
 (0)