mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-10-10 17:49:40 +02:00
#1295 Better way of finding suitable child in cluster to point to
This commit is contained in:
@@ -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
|
||||||
|
@@ -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' };
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user