From a82c53dd2e802836edf2011f6f9ca9c352431628 Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Sat, 29 Aug 2020 16:11:42 +0200 Subject: [PATCH] Not moving the label away from assigned position --- cypress/platform/current.html | 8 ++++++-- src/dagre-wrapper/edges.js | 9 +++++---- src/diagrams/flowchart/flowDb.js | 4 ++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/cypress/platform/current.html b/cypress/platform/current.html index 6297d39b6..9c62cdc7a 100644 --- a/cypress/platform/current.html +++ b/cypress/platform/current.html @@ -76,8 +76,12 @@ stateDiagram-v2
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#ff0000'}}}%% -classDiagram - Animal <|-- Duck +flowchart TD +%%subgraph A + C -->|Label1 long long long| E1 + C --> E3 + C ==>E3 +%%end
diff --git a/src/dagre-wrapper/edges.js b/src/dagre-wrapper/edges.js index ce9d58c9e..f6763dd17 100644 --- a/src/dagre-wrapper/edges.js +++ b/src/dagre-wrapper/edges.js @@ -39,7 +39,7 @@ export const insertEdgeLabel = (elem, edge) => { edgeLabels[edge.id] = edgeLabel; // Update the abstract data of the edge with the new information about its width and height - edge.width = bbox.width + 40; + edge.width = bbox.width; edge.height = bbox.height; if (edge.startLabelLeft) { @@ -111,10 +111,11 @@ export const positionEdgeLabel = (edge, paths) => { let x = edge.x; let y = edge.y; if (path) { - // debugger; + // // debugger; const pos = utils.calcLabelPosition(path); - x = pos.x; - y = pos.y; + logger.info('Moving label from (', x, ',', y, ') to (', pos.x, ',', pos.y, ')'); + // x = pos.x; + // y = pos.y; } el.attr('transform', 'translate(' + x + ', ' + y + ')'); } diff --git a/src/diagrams/flowchart/flowDb.js b/src/diagrams/flowchart/flowDb.js index 7a2269acf..a18e23c43 100644 --- a/src/diagrams/flowchart/flowDb.js +++ b/src/diagrams/flowchart/flowDb.js @@ -7,7 +7,7 @@ import mermaidAPI from '../../mermaidAPI'; // const MERMAID_DOM_ID_PREFIX = 'mermaid-dom-id-'; const MERMAID_DOM_ID_PREFIX = ''; -let config = configApi.defaultConfig; +let config = configApi.getConfig(); let vertices = {}; let edges = []; let classes = []; @@ -48,7 +48,7 @@ export const addVertex = function(_id, text, type, style, classes) { vertices[id] = { id: id, styles: [], classes: [] }; } if (typeof text !== 'undefined') { - config = configApi.defaultConfig; + config = configApi.getConfig(); txt = common.sanitizeText(text.trim(), config); // strip quotes if string starts and ends with a quote