Skip to content

Commit 81697fc

Browse files
committed
make sure annotations/shape plot-schema 'items' don't get a role
1 parent 07f1b2e commit 81697fc

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

shelly/plotlyjs/static/plotlyjs/src/plotschema.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ var extendDeepAll = Plotly.Lib.extendDeepAll;
99
var NESTED_MODULE = '_nestedModules',
1010
COMPOSED_MODULE = '_composedModules',
1111
IS_SUBPLOT_OBJ = '_isSubplotObj',
12-
IS_LINKED_TO_ARRAY = '_isLinkedToArray';
12+
IS_LINKED_TO_ARRAY = '_isLinkedToArray',
13+
DEPRECATED = '_deprecated';
1314

1415
// list of underscore attributes to keep in schema as is
15-
var UNDERSCORE_ATTRS = ['_isSubplotObj', '_deprecated'];
16+
var UNDERSCORE_ATTRS = [IS_SUBPLOT_OBJ, IS_LINKED_TO_ARRAY, DEPRECATED];
1617

1718
var plotSchema = {
1819
traces: {},
@@ -115,11 +116,12 @@ function getLayoutAttributes() {
115116
// add IS_SUBPLOT_OBJ attribute
116117
layoutAttributes = handleSubplotObjs(layoutAttributes);
117118

119+
layoutAttributes = removeUnderscoreAttrs(layoutAttributes);
120+
mergeValTypeAndRole(layoutAttributes);
121+
118122
// generate IS_LINKED_TO_ARRAY structure
119123
layoutAttributes = handleLinkedToArray(layoutAttributes);
120124

121-
layoutAttributes = removeUnderscoreAttrs(layoutAttributes);
122-
mergeValTypeAndRole(layoutAttributes);
123125
plotSchema.layout = { layoutAttributes: layoutAttributes };
124126
}
125127

@@ -278,19 +280,17 @@ function handleSubplotObjs(layoutAttributes) {
278280

279281
function handleLinkedToArray(layoutAttributes) {
280282
Object.keys(layoutAttributes).forEach(function(k) {
281-
var attr = clone(layoutAttributes[k]);
283+
var attr = extendDeep({}, layoutAttributes[k]);
282284

283285
if(attr[IS_LINKED_TO_ARRAY] !== true) return;
284286

285287
var itemName = k.substr(0, k.length-1); // TODO more robust logic
286288

287289
delete attr[IS_LINKED_TO_ARRAY];
288290

289-
layoutAttributes[k] = {
290-
role: 'object',
291-
items: {}
292-
};
291+
layoutAttributes[k] = { items: {} };
293292
layoutAttributes[k].items[itemName] = attr;
293+
layoutAttributes[k].role = 'object';
294294
});
295295

296296
return layoutAttributes;

0 commit comments

Comments
 (0)