mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-11-16 02:34:41 +01:00
Not moving the label away from assigned position
This commit is contained in:
@@ -76,8 +76,12 @@ stateDiagram-v2
|
|||||||
</div>
|
</div>
|
||||||
<div class="mermaid" style="width: 50%; height: 20%;">
|
<div class="mermaid" style="width: 50%; height: 20%;">
|
||||||
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#ff0000'}}}%%
|
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#ff0000'}}}%%
|
||||||
classDiagram
|
flowchart TD
|
||||||
Animal <|-- Duck
|
%%subgraph A
|
||||||
|
C -->|Label1 long long long| E1
|
||||||
|
C --> E3
|
||||||
|
C ==>E3
|
||||||
|
%%end
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="mermaid2" style="width: 50%; height: 20%;">
|
<div class="mermaid2" style="width: 50%; height: 20%;">
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export const insertEdgeLabel = (elem, edge) => {
|
|||||||
edgeLabels[edge.id] = edgeLabel;
|
edgeLabels[edge.id] = edgeLabel;
|
||||||
|
|
||||||
// Update the abstract data of the edge with the new information about its width and height
|
// 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;
|
edge.height = bbox.height;
|
||||||
|
|
||||||
if (edge.startLabelLeft) {
|
if (edge.startLabelLeft) {
|
||||||
@@ -111,10 +111,11 @@ export const positionEdgeLabel = (edge, paths) => {
|
|||||||
let x = edge.x;
|
let x = edge.x;
|
||||||
let y = edge.y;
|
let y = edge.y;
|
||||||
if (path) {
|
if (path) {
|
||||||
// debugger;
|
// // debugger;
|
||||||
const pos = utils.calcLabelPosition(path);
|
const pos = utils.calcLabelPosition(path);
|
||||||
x = pos.x;
|
logger.info('Moving label from (', x, ',', y, ') to (', pos.x, ',', pos.y, ')');
|
||||||
y = pos.y;
|
// x = pos.x;
|
||||||
|
// y = pos.y;
|
||||||
}
|
}
|
||||||
el.attr('transform', 'translate(' + x + ', ' + y + ')');
|
el.attr('transform', 'translate(' + x + ', ' + y + ')');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import mermaidAPI from '../../mermaidAPI';
|
|||||||
// const MERMAID_DOM_ID_PREFIX = 'mermaid-dom-id-';
|
// const MERMAID_DOM_ID_PREFIX = 'mermaid-dom-id-';
|
||||||
const MERMAID_DOM_ID_PREFIX = '';
|
const MERMAID_DOM_ID_PREFIX = '';
|
||||||
|
|
||||||
let config = configApi.defaultConfig;
|
let config = configApi.getConfig();
|
||||||
let vertices = {};
|
let vertices = {};
|
||||||
let edges = [];
|
let edges = [];
|
||||||
let classes = [];
|
let classes = [];
|
||||||
@@ -48,7 +48,7 @@ export const addVertex = function(_id, text, type, style, classes) {
|
|||||||
vertices[id] = { id: id, styles: [], classes: [] };
|
vertices[id] = { id: id, styles: [], classes: [] };
|
||||||
}
|
}
|
||||||
if (typeof text !== 'undefined') {
|
if (typeof text !== 'undefined') {
|
||||||
config = configApi.defaultConfig;
|
config = configApi.getConfig();
|
||||||
txt = common.sanitizeText(text.trim(), config);
|
txt = common.sanitizeText(text.trim(), config);
|
||||||
|
|
||||||
// strip quotes if string starts and ends with a quote
|
// strip quotes if string starts and ends with a quote
|
||||||
|
|||||||
Reference in New Issue
Block a user