#1295 Better way of finding suitable child in cluster to point to

This commit is contained in:
Knut Sveidqvist
2020-04-02 19:48:28 +02:00
parent 365c741864
commit cff68fc062
2 changed files with 20 additions and 4 deletions

View File

@@ -31,7 +31,7 @@
G-->H G-->H
G-->c G-->c
</div> </div>
<div class="mermaid2" style="width: 50%; height: 20%;"> <div class="mermaid" style="width: 50%; height: 20%;">
stateDiagram-v2 stateDiagram-v2
[*] --> monkey [*] --> monkey
state monkey { state monkey {
@@ -85,7 +85,7 @@ stateDiagram-v2
sec --> [*] sec --> [*]
} }
</div> </div>
<div class="mermaid" style="width: 100%; height: 100%;"> <div class="mermaid2" style="width: 100%; height: 100%;">
stateDiagram-v2 stateDiagram-v2
[*] --> First [*] --> First
First --> Second First --> Second

View File

@@ -32,6 +32,22 @@ const getAnchorId = (id, graph, nodes) => {
return id; return id;
}; };
const findNonClusterChild = (id, graph) => {
const node = graph.node(id);
logger.info('identified node', node);
if (node.type !== 'group') {
return node.id;
}
logger.info('identified node Not', node.id);
const children = graph.children(id);
for (let i = 0; i < children.length; i++) {
const _id = findNonClusterChild(children[i], graph);
if (_id) {
return _id;
}
}
};
export const render = (elem, graph, markers, diagramtype, id) => { export const render = (elem, graph, markers, diagramtype, id) => {
insertMarkers(elem, markers, diagramtype, id); insertMarkers(elem, markers, diagramtype, id);
clusterDb = {}; clusterDb = {};
@@ -55,9 +71,9 @@ export const render = (elem, graph, markers, diagramtype, id) => {
// const width = getClusterTitleWidth(clusters, node); // const width = getClusterTitleWidth(clusters, node);
const children = graph.children(v); const children = graph.children(v);
logger.info('Cluster identified', node.id, children[0]); logger.info('Cluster identified', node.id, children[0], findNonClusterChild(node.id, graph));
// nodes2expand.push({ id: children[0], width }); // nodes2expand.push({ id: children[0], width });
clusterDb[node.id] = { id: children[0] }; clusterDb[node.id] = { id: findNonClusterChild(node.id, graph) };
// clusterDb[node.id] = { id: node.id + '_anchor' }; // clusterDb[node.id] = { id: node.id + '_anchor' };
} }
}); });