Skip to content

Commit 4c49755

Browse files
committed
make clean data work for non-plain-object annotation / shape items
1 parent 69bffe1 commit 4c49755

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/plot_api/helpers.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,12 @@ exports.cleanLayout = function(layout) {
102102
}
103103
}
104104

105-
if(layout.annotations !== undefined && !Array.isArray(layout.annotations)) {
106-
Lib.warn('Annotations must be an array.');
107-
delete layout.annotations;
108-
}
109105
var annotationsLen = (layout.annotations || []).length;
110106
for(i = 0; i < annotationsLen; i++) {
111107
var ann = layout.annotations[i];
108+
109+
if(!Lib.isPlainObject(ann)) continue;
110+
112111
if(ann.ref) {
113112
if(ann.ref === 'paper') {
114113
ann.xref = 'paper';
@@ -120,17 +119,17 @@ exports.cleanLayout = function(layout) {
120119
}
121120
delete ann.ref;
122121
}
122+
123123
cleanAxRef(ann, 'xref');
124124
cleanAxRef(ann, 'yref');
125125
}
126126

127-
if(layout.shapes !== undefined && !Array.isArray(layout.shapes)) {
128-
Lib.warn('Shapes must be an array.');
129-
delete layout.shapes;
130-
}
131127
var shapesLen = (layout.shapes || []).length;
132128
for(i = 0; i < shapesLen; i++) {
133129
var shape = layout.shapes[i];
130+
131+
if(!Lib.isPlainObject(shape)) continue;
132+
134133
cleanAxRef(shape, 'xref');
135134
cleanAxRef(shape, 'yref');
136135
}

0 commit comments

Comments
 (0)