Skip to content

Commit e060375

Browse files
committed
fix subplotRegistry logic to handle sub-bundle cases
1 parent c3cf9e4 commit e060375

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

shelly/plotlyjs/static/plotlyjs/src/graph_obj.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ plots.registerSubplot = function(subplotType, attr, idRoot, attributes) {
150150

151151
// TODO separate the 'find subplot' step from the 'get subplot ids' step
152152
plots.getSubplotIds = function getSubplotIds(layout, type) {
153+
if(plots.subplotsRegistry[type] === undefined) return [];
153154

154155
// layout must be 'fullLayout' here
155156
if(type === 'cartesian') {
@@ -170,6 +171,8 @@ plots.getSubplotIds = function getSubplotIds(layout, type) {
170171
};
171172

172173
plots.getSubplotIdsInData = function getSubplotsInData(data, type) {
174+
if(plots.subplotsRegistry[type] === undefined) return [];
175+
173176
var attr = plots.subplotsRegistry[type].attr,
174177
subplotIds = [],
175178
trace;
@@ -185,6 +188,8 @@ plots.getSubplotIdsInData = function getSubplotsInData(data, type) {
185188
};
186189

187190
plots.getSubplotData = function getSubplotData(data, type, subplotId) {
191+
if(plots.subplotsRegistry[type] === undefined) return [];
192+
188193
var attr = plots.subplotsRegistry[type].attr,
189194
subplotData = [],
190195
trace;

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

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -264,15 +264,23 @@ function getSubplotRegistry(traceType) {
264264
function handleSubplotObjs(layoutAttributes) {
265265
var subplotsRegistry = Plotly.Plots.subplotsRegistry;
266266

267-
var gl3dRegex = subplotsRegistry.gl3d.attrRegex,
268-
geoRegex = subplotsRegistry.geo.attrRegex,
269-
xaxisRegex = subplotsRegistry.cartesian.attrRegex.x,
270-
yaxisRegex = subplotsRegistry.cartesian.attrRegex.y;
271-
272267
Object.keys(layoutAttributes).forEach(function(k) {
273-
if(gl3dRegex.test(k) || geoRegex.test(k) || xaxisRegex.test(k) || yaxisRegex.test(k)) {
274-
layoutAttributes[k][IS_SUBPLOT_OBJ] = true;
275-
}
268+
Object.keys(subplotsRegistry).forEach(function(subplotType) {
269+
var subplotRegistry = subplotsRegistry[subplotType],
270+
isSubplotObj;
271+
272+
if(subplotType === 'cartesian') {
273+
isSubplotObj = (
274+
subplotRegistry.attrRegex.x.test(k) ||
275+
subplotRegistry.attrRegex.y.test(k)
276+
);
277+
}
278+
else {
279+
isSubplotObj = subplotRegistry.attrRegex.test(k);
280+
}
281+
282+
if(isSubplotObj) layoutAttributes[k][IS_SUBPLOT_OBJ] = true;
283+
});
276284
});
277285

278286
return layoutAttributes;

0 commit comments

Comments
 (0)