#1958 Handling multiple edges from and to the same node tuple
This commit is contained in:
parent
4e6b9ec947
commit
11f3cbdb36
|
@ -598,4 +598,16 @@ flowchart RL
|
||||||
{htmlLabels: true, flowchart: {htmlLabels: true}, securityLevel: 'loose'}
|
{htmlLabels: true, flowchart: {htmlLabels: true}, securityLevel: 'loose'}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
it('74: Handle labels for multiple edges from and to the same couple of nodes', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
`
|
||||||
|
flowchart RL
|
||||||
|
subgraph one
|
||||||
|
a1 -- l1 --> a2
|
||||||
|
a1 -- l2 --> a2
|
||||||
|
end
|
||||||
|
`,
|
||||||
|
{htmlLabels: true, flowchart: {htmlLabels: true}, securityLevel: 'loose'}
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -56,16 +56,11 @@ flowchart TD
|
||||||
linkStyle 0,1 color:orange, stroke: orange;
|
linkStyle 0,1 color:orange, stroke: orange;
|
||||||
</div>
|
</div>
|
||||||
<div class="mermaid" style="width: 100%; height: 20%;">
|
<div class="mermaid" style="width: 100%; height: 20%;">
|
||||||
flowchart TB
|
flowchart RL
|
||||||
subgraph two
|
subgraph two
|
||||||
b1
|
a1 -- l1 --> a2
|
||||||
|
a1 -- l2 --> a2
|
||||||
end
|
end
|
||||||
subgraph three
|
|
||||||
c2
|
|
||||||
end
|
|
||||||
|
|
||||||
three --> two
|
|
||||||
two --> c2
|
|
||||||
</div>
|
</div>
|
||||||
<div class="mermaid2" style="width: 100%; height: 20%;">
|
<div class="mermaid2" style="width: 100%; height: 20%;">
|
||||||
flowchart TB
|
flowchart TB
|
||||||
|
|
|
@ -105,7 +105,7 @@ export const insertEdgeLabel = (elem, edge) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const positionEdgeLabel = (edge, paths) => {
|
export const positionEdgeLabel = (edge, paths) => {
|
||||||
log.info('Moving label', edge.id, edge.label, edgeLabels[edge.id]);
|
log.info('Moving label abc78 ', edge.id, edge.label, edgeLabels[edge.id]);
|
||||||
let path = paths.updatedPath ? paths.updatedPath : paths.originalPath;
|
let path = paths.updatedPath ? paths.updatedPath : paths.originalPath;
|
||||||
if (edge.label) {
|
if (edge.label) {
|
||||||
const el = edgeLabels[edge.id];
|
const el = edgeLabels[edge.id];
|
||||||
|
@ -114,7 +114,7 @@ export const positionEdgeLabel = (edge, paths) => {
|
||||||
if (path) {
|
if (path) {
|
||||||
// // debugger;
|
// // debugger;
|
||||||
const pos = utils.calcLabelPosition(path);
|
const pos = utils.calcLabelPosition(path);
|
||||||
log.info('Moving label from (', x, ',', y, ') to (', pos.x, ',', pos.y, ')');
|
log.info('Moving label from (', x, ',', y, ') to (', pos.x, ',', pos.y, ') abc78');
|
||||||
// x = pos.x;
|
// x = pos.x;
|
||||||
// y = pos.y;
|
// y = pos.y;
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,7 +174,9 @@ export const addVertices = function(vert, g, svgId) {
|
||||||
* @param {Object} g The graph object
|
* @param {Object} g The graph object
|
||||||
*/
|
*/
|
||||||
export const addEdges = function(edges, g) {
|
export const addEdges = function(edges, g) {
|
||||||
|
log.info('abc78 edges = ', edges);
|
||||||
let cnt = 0;
|
let cnt = 0;
|
||||||
|
let linkIdCnt = {};
|
||||||
|
|
||||||
let defaultStyle;
|
let defaultStyle;
|
||||||
let defaultLabelStyle;
|
let defaultLabelStyle;
|
||||||
|
@ -189,7 +191,17 @@ export const addEdges = function(edges, g) {
|
||||||
cnt++;
|
cnt++;
|
||||||
|
|
||||||
// Identify Link
|
// Identify Link
|
||||||
var linkId = 'L-' + edge.start + '-' + edge.end;
|
var linkIdBase = 'L-' + edge.start + '-' + edge.end;
|
||||||
|
// count the links from+to the same node to give unique id
|
||||||
|
if (typeof linkIdCnt[linkIdBase] === 'undefined') {
|
||||||
|
linkIdCnt[linkIdBase] = 0;
|
||||||
|
log.info('abc78 new entry', linkIdBase, linkIdCnt[linkIdBase]);
|
||||||
|
} else {
|
||||||
|
linkIdCnt[linkIdBase]++;
|
||||||
|
log.info('abc78 new entry', linkIdBase, linkIdCnt[linkIdBase]);
|
||||||
|
}
|
||||||
|
let linkId = linkIdBase + '-' + linkIdCnt[linkIdBase];
|
||||||
|
log.info('abc78 new link id to be used is', linkIdBase, linkId, linkIdCnt[linkIdBase]);
|
||||||
var linkNameStart = 'LS-' + edge.start;
|
var linkNameStart = 'LS-' + edge.start;
|
||||||
var linkNameEnd = 'LE-' + edge.end;
|
var linkNameEnd = 'LE-' + edge.end;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue