Skip to content

Commit 5616d1b

Browse files
committed
handle arbitrary properties (eg width) in dagre callback graph layout
1 parent 06a4178 commit 5616d1b

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

dash-renderer/src/components/error/CallbackGraph/CallbackGraphContainer.react.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,33 +32,34 @@ function generateElements(graphs, profile) {
3232
const idStr = stringifyId(id);
3333
const idType = typeof id === 'object' ? 'wildcard' : 'component';
3434

35-
const parent = idStr;
36-
const child = `${idStr}.${property}`;
35+
// dagre layout has problems with eg `width` property - so prepend an X
36+
const parentId = idStr;
37+
const childId = `${parentId}.X${property}`;
3738

38-
if (!consumed.includes(parent)) {
39-
consumed.push(parent);
39+
if (!consumed.includes(parentId)) {
40+
consumed.push(parentId);
4041
elements.push({
4142
data: {
42-
id: idStr,
43+
id: parentId,
4344
label: idStr,
4445
type: idType
4546
}
4647
});
4748
}
4849

49-
if (!consumed.includes(child)) {
50-
consumed.push(child);
50+
if (!consumed.includes(childId)) {
51+
consumed.push(childId);
5152
elements.push({
5253
data: {
53-
id: child,
54+
id: childId,
5455
label: property,
55-
parent: parent,
56+
parent: parentId,
5657
type: 'property'
5758
}
5859
});
5960
}
6061

61-
return child;
62+
return childId;
6263
}
6364

6465
function recordEdge(source, target, type) {
@@ -91,18 +92,18 @@ function generateElements(graphs, profile) {
9192
});
9293

9394
callback.outputs.map(({id, property}) => {
94-
const node = recordNode(id, property);
95-
recordEdge(cb, node, 'output');
95+
const nodeId = recordNode(id, property);
96+
recordEdge(cb, nodeId, 'output');
9697
});
9798

9899
callback.inputs.map(({id, property}) => {
99-
const node = recordNode(id, property);
100-
recordEdge(node, cb, 'input');
100+
const nodeId = recordNode(id, property);
101+
recordEdge(nodeId, cb, 'input');
101102
});
102103

103104
callback.state.map(({id, property}) => {
104-
const node = recordNode(id, property);
105-
recordEdge(node, cb, 'state');
105+
const nodeId = recordNode(id, property);
106+
recordEdge(nodeId, cb, 'state');
106107
});
107108
});
108109

0 commit comments

Comments
 (0)