Better track of the order of the edge and removing debug code

This commit is contained in:
Knut Sveidqvist 2021-04-29 19:24:07 +02:00
parent 8955e0a6b1
commit ce84278f10
2 changed files with 30 additions and 26 deletions

View File

@ -55,18 +55,20 @@ flowchart TD
class T TestSub class T TestSub
linkStyle 0,1 color:orange, stroke: orange; linkStyle 0,1 color:orange, stroke: orange;
</div> </div>
<div class="mermaid2" style="width: 100%; height: 20%;"> <div class="mermaid" style="width: 100%; height: 20%;">
flowchart TB flowchart TB
subgraph S1
sub1 -->sub2 subgraph two
end b1
subgraph S2 end
sub4 subgraph three
end c2
S1 --> S2 end
sub1 --> sub4
three --> two
two --> c2
</div> </div>
<div class="mermaid" style="width: 100%; height: 20%;"> <div class="mermaid2" style="width: 100%; height: 20%;">
flowchart TB flowchart TB
c1-->a2 c1-->a2
subgraph one subgraph one

View File

@ -1,6 +1,7 @@
import { log } from '../logger'; // eslint-disable-line import { log } from '../logger'; // eslint-disable-line
import createLabel from './createLabel'; import createLabel from './createLabel';
import { line, curveBasis, curveLinear, select } from 'd3'; // import { line, curveBasis, curveLinear, select } from 'd3';
import { line, curveBasis, select } from 'd3';
import { getConfig } from '../config'; import { getConfig } from '../config';
import utils from '../utils'; import utils from '../utils';
// import { calcLabelPosition } from '../utils'; // import { calcLabelPosition } from '../utils';
@ -299,7 +300,7 @@ const cutPathAtIntersect = (_points, boundryNode) => {
let isInside = false; let isInside = false;
_points.forEach(point => { _points.forEach(point => {
// const node = clusterDb[edge.toCluster].node; // const node = clusterDb[edge.toCluster].node;
log.warn('abc88 checking point', point, boundryNode); log.info('abc88 checking point', point, boundryNode);
// check if point is inside the boundry rect // check if point is inside the boundry rect
if (!outsideNode(boundryNode, point) && !isInside) { if (!outsideNode(boundryNode, point) && !isInside) {
@ -341,6 +342,7 @@ export const insertEdge = function(elem, e, edge, clusterDb, diagramType, graph)
const tail = graph.node(e.v); const tail = graph.node(e.v);
var head = graph.node(e.w); var head = graph.node(e.w);
log.info('abc88 InsertEdge: ', edge);
if (head.intersect && tail.intersect) { if (head.intersect && tail.intersect) {
points = points.slice(1, edge.points.length - 1); points = points.slice(1, edge.points.length - 1);
points.unshift(tail.intersect(points[0])); points.unshift(tail.intersect(points[0]));
@ -353,8 +355,8 @@ export const insertEdge = function(elem, e, edge, clusterDb, diagramType, graph)
points.push(head.intersect(points[points.length - 1])); points.push(head.intersect(points[points.length - 1]));
} }
if (edge.toCluster) { if (edge.toCluster) {
log.warn('to cluster abc88', clusterDb[edge.toCluster]); log.info('to cluster abc88', clusterDb[edge.toCluster]);
points = cutPathAtIntersect(edge.points, clusterDb[edge.toCluster].node).reverse(); points = cutPathAtIntersect(edge.points, clusterDb[edge.toCluster].node);
// log.trace('edge', edge); // log.trace('edge', edge);
// points = []; // points = [];
// let lastPointOutside; // = edge.points[0]; // let lastPointOutside; // = edge.points[0];
@ -390,8 +392,8 @@ export const insertEdge = function(elem, e, edge, clusterDb, diagramType, graph)
} }
if (edge.fromCluster) { if (edge.fromCluster) {
log.warn('from cluster abc88', clusterDb[edge.fromCluster]); log.info('from cluster abc88', clusterDb[edge.fromCluster]);
points = cutPathAtIntersect(points, clusterDb[edge.fromCluster].node).reverse(); points = cutPathAtIntersect(points.reverse(), clusterDb[edge.fromCluster].node).reverse();
// log.warn('edge', edge); // log.warn('edge', edge);
// log.warn('from cluster', clusterDb[edge.fromCluster], points); // log.warn('from cluster', clusterDb[edge.fromCluster], points);
// const updatedPoints = []; // const updatedPoints = [];
@ -447,7 +449,7 @@ export const insertEdge = function(elem, e, edge, clusterDb, diagramType, graph)
} else { } else {
curve = curveBasis; curve = curveBasis;
} }
curve = curveLinear; // curve = curveLinear;
const lineFunction = line() const lineFunction = line()
.x(function(d) { .x(function(d) {
return d.x; return d.x;
@ -489,15 +491,15 @@ export const insertEdge = function(elem, e, edge, clusterDb, diagramType, graph)
.attr('style', edge.style); .attr('style', edge.style);
// DEBUG code, adds a red circle at each edge coordinate // DEBUG code, adds a red circle at each edge coordinate
edge.points.forEach(point => { // edge.points.forEach(point => {
elem // elem
.append('circle') // .append('circle')
.style('stroke', 'red') // .style('stroke', 'red')
.style('fill', 'red') // .style('fill', 'red')
.attr('r', 1) // .attr('r', 1)
.attr('cx', point.x) // .attr('cx', point.x)
.attr('cy', point.y); // .attr('cy', point.y);
}); // });
let url = ''; let url = '';
if (getConfig().state.arrowMarkerAbsolute) { if (getConfig().state.arrowMarkerAbsolute) {