#3358 Reviving arrow heads after merging develop

This commit is contained in:
Knut Sveidqvist 2024-01-19 14:57:45 +01:00
parent b4dece88e9
commit d96425d19e
4 changed files with 20 additions and 11 deletions

View File

@ -65,12 +65,12 @@
<body> <body>
<pre id="diagram" class="mermaid"> <pre id="diagram" class="mermaid">
block-beta block-beta
A space:2 B a space:2 c
A-- "X" -->B a-- "b" --> c
</pre> </pre>
<pre id="diagram" class="mermaid"> <pre id="diagram" class="mermaid">
flowchart LR flowchart LR
A-- "X" -->B X-- "y" -->z
</pre> </pre>
<pre id="diagram" class="mermaid2"> <pre id="diagram" class="mermaid2">
block-beta block-beta

View File

@ -134,7 +134,7 @@ function setTerminalWidth(fo, value) {
} }
export const positionEdgeLabel = (edge, paths) => { export const positionEdgeLabel = (edge, paths) => {
log.info('Moving label abc78 ', edge.id, edge.label, edgeLabels[edge.id]); log.info('Moving label abc88 ', edge.id, edge.label, edgeLabels[edge.id], paths);
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];
@ -152,7 +152,7 @@ export const positionEdgeLabel = (edge, paths) => {
pos.x, pos.x,
',', ',',
pos.y, pos.y,
') abc78' ') abc88'
); );
if (paths.updatedPath) { if (paths.updatedPath) {
x = pos.x; x = pos.x;
@ -376,7 +376,7 @@ export const insertEdge = function (elem, e, edge, clusterDb, diagramType, graph
let pointsHasChanged = false; let pointsHasChanged = false;
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 (head & tail): ', e.v, head, ' --- ', e.w, tail); log.info('abc88 InsertEdge (head & tail) fin: ', e.v, head, ' --- ', e.w, tail);
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);

View File

@ -58,7 +58,8 @@ export const draw = async function (
// Add the marker definitions to the svg as marker tags // Add the marker definitions to the svg as marker tags
// insertMarkers(svg, markers, diagObj.type, diagObj.arrowMarkerAbsolute); // insertMarkers(svg, markers, diagObj.type, diagObj.arrowMarkerAbsolute);
insertMarkers(svg, markers, diagObj.type, true); // insertMarkers(svg, markers, diagObj.type, true);
insertMarkers(svg, markers, diagObj.type, id);
const bl = db.getBlocks(); const bl = db.getBlocks();
const blArr = db.getBlocksFlat(); const blArr = db.getBlocksFlat();
@ -69,7 +70,7 @@ export const draw = async function (
const bounds = layout(db); const bounds = layout(db);
// log.debug('Here be blocks', bl); // log.debug('Here be blocks', bl);
await insertBlocks(nodes, bl, db); await insertBlocks(nodes, bl, db);
await insertEdges(nodes, edges, blArr, db); await insertEdges(nodes, edges, blArr, db, id);
// log.debug('Here', bl); // log.debug('Here', bl);

View File

@ -1,6 +1,6 @@
import { getStylesFromArray } from '../../utils.js'; import { getStylesFromArray } from '../../utils.js';
import { insertNode, positionNode } from '../../dagre-wrapper/nodes.js'; import { insertNode, positionNode } from '../../dagre-wrapper/nodes.js';
import { insertEdge, insertEdgeLabel } from '../../dagre-wrapper/edges.js'; import { insertEdge, insertEdgeLabel, positionEdgeLabel } from '../../dagre-wrapper/edges.js';
import * as graphlib from 'dagre-d3-es/src/graphlib/index.js'; import * as graphlib from 'dagre-d3-es/src/graphlib/index.js';
import { getConfig } from '../../config.js'; import { getConfig } from '../../config.js';
import type { ContainerElement } from 'd3'; import type { ContainerElement } from 'd3';
@ -185,7 +185,8 @@ export async function insertEdges(
elem: ContainerElement, elem: ContainerElement,
edges: Block[], edges: Block[],
blocks: Block[], blocks: Block[],
db: BlockDB db: BlockDB,
id: string
) { ) {
const g = new graphlib.Graph({ const g = new graphlib.Graph({
multigraph: true, multigraph: true,
@ -238,7 +239,8 @@ export async function insertEdges(
}, },
undefined, undefined,
'block', 'block',
g g,
id
); );
if (edge.label) { if (edge.label) {
await insertEdgeLabel(elem, { await insertEdgeLabel(elem, {
@ -250,6 +252,12 @@ export async function insertEdges(
points, points,
classes: 'edge-thickness-normal edge-pattern-solid flowchart-link LS-a1 LE-b1', classes: 'edge-thickness-normal edge-pattern-solid flowchart-link LS-a1 LE-b1',
}); });
await positionEdgeLabel(
{ ...edge, x: points[1].x, y: points[1].y },
{
originalPath: points,
}
);
} }
} }
} }