From 1f4be7766224efdd574bcdec9c9f8bd9c848ae02 Mon Sep 17 00:00:00 2001 From: Marc Faber Date: Tue, 10 Dec 2019 03:48:12 +0100 Subject: [PATCH] Revert "#910 set correct position and style for edge labels when using linkStyle, #1088 handle multiline texts in edge labels when using linkStyle" - Sorry, forgot to push to a new branch. This reverts commit 0deae4abf9674be4831dd4cbf18468c704999f12. --- dist/index.html | 12 --------- src/diagrams/flowchart/flowRenderer.js | 20 +++++++------- src/diagrams/flowchart/flowRenderer.spec.js | 30 +-------------------- 3 files changed, 11 insertions(+), 51 deletions(-) diff --git a/dist/index.html b/dist/index.html index 615c9a537..eb27c6593 100644 --- a/dist/index.html +++ b/dist/index.html @@ -313,18 +313,6 @@ class A someclass; classDef someclass fill:#f96; class A someclass; -
- graph LR - A1[Multi
Line] -->|Multi
Line| B1(Multi
Line) - C1[Multi
Line] -->|Multi
Line| D1(Multi
Line) - E1[Multi
Line] -->|Multi
Line| F1(Multi
Line) - A2[Multi
Line] -->|Multi
Line| B2(Multi
Line) - C2[Multi
Line] -->|Multi
Line| D2(Multi
Line) - E2[Multi
Line] -->|Multi
Line| F2(Multi
Line) - linkStyle 0 stroke:DarkGray,stroke-width:2px - linkStyle 1 stroke:DarkGray,stroke-width:2px - linkStyle 2 stroke:DarkGray,stroke-width:2px -

diff --git a/src/diagrams/flowchart/flowRenderer.js b/src/diagrams/flowchart/flowRenderer.js index 524742b39..ee680532f 100644 --- a/src/diagrams/flowchart/flowRenderer.js +++ b/src/diagrams/flowchart/flowRenderer.js @@ -239,18 +239,18 @@ export const addEdges = function(edges, g) { } } else { edgeData.arrowheadStyle = 'fill: #333'; - edgeData.labelpos = 'c'; - - if (getConfig().flowchart.htmlLabels) { - edgeData.labelType = 'html'; - edgeData.label = '' + edge.text + ''; - } else { - edgeData.labelType = 'text'; - edgeData.label = edge.text.replace(/
/g, '\n'); - - if (typeof edge.style === 'undefined') { + if (typeof edge.style === 'undefined') { + edgeData.labelpos = 'c'; + if (getConfig().flowchart.htmlLabels) { + edgeData.labelType = 'html'; + edgeData.label = '' + edge.text + ''; + } else { + edgeData.labelType = 'text'; edgeData.style = edgeData.style || 'stroke: #333; stroke-width: 1.5px;fill:none'; + edgeData.label = edge.text.replace(/
/g, '\n'); } + } else { + edgeData.label = edge.text.replace(/
/g, '\n'); } } // Add the edge to the graph diff --git a/src/diagrams/flowchart/flowRenderer.spec.js b/src/diagrams/flowchart/flowRenderer.spec.js index fe31292cc..0e49dbf71 100644 --- a/src/diagrams/flowchart/flowRenderer.spec.js +++ b/src/diagrams/flowchart/flowRenderer.spec.js @@ -1,4 +1,4 @@ -import { addVertices, addEdges } from './flowRenderer'; +import { addVertices } from './flowRenderer'; import { setConfig } from '../../config'; setConfig({ @@ -94,32 +94,4 @@ describe('the flowchart renderer', function() { expect(addedNodes[0][1]).toHaveProperty('labelStyle', expectedLabelStyle); }); }); - - describe('when adding edges to a graph', function() { - it('should handle multiline texts and set centered label position', function() { - const addedEdges = []; - const mockG = { - setEdge: function(s, e, data, c) { - addedEdges.push(data); - } - }; - addEdges( - [ - { text: 'Multi
Line' }, - { text: 'Multi
Line' }, - { text: 'Multi
Line' }, - { style: ['stroke:DarkGray', 'stroke-width:2px'], text: 'Multi
Line' }, - { style: ['stroke:DarkGray', 'stroke-width:2px'], text: 'Multi
Line' }, - { style: ['stroke:DarkGray', 'stroke-width:2px'], text: 'Multi
Line' } - ], - mockG, - 'svg-id' - ); - - addedEdges.forEach(function(edge) { - expect(edge).toHaveProperty('label', 'Multi\nLine'); - expect(edge).toHaveProperty('labelpos', 'c'); - }); - }); - }); });