From f6377e6125bd081c8d0170384c4822c2a9b8ded8 Mon Sep 17 00:00:00 2001 From: Eduardas Michelsonas Date: Wed, 28 Aug 2019 20:09:45 +0200 Subject: [PATCH 1/2] #755 --- src/diagrams/sequence/sequenceRenderer.js | 27 +++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/diagrams/sequence/sequenceRenderer.js b/src/diagrams/sequence/sequenceRenderer.js index 4e4b0f74d..b1282fbea 100644 --- a/src/diagrams/sequence/sequenceRenderer.js +++ b/src/diagrams/sequence/sequenceRenderer.js @@ -211,35 +211,44 @@ const drawMessage = function (elem, startx, stopx, verticalPos, msg, sequenceInd const g = elem.append('g') const txtCenter = startx + (stopx - startx) / 2 - const textElem = g.append('text') // text label for the x axis + let textElem + let counterBreaklines = 0 + let breaklineOffset = 17 + const breaklines = msg.message.split(//ig) + for (const breakline of breaklines) { + textElem = g.append('text') // text label for the x axis .attr('x', txtCenter) - .attr('y', verticalPos - 7) + .attr('y', verticalPos - 7 + counterBreaklines * breaklineOffset) .style('text-anchor', 'middle') .attr('class', 'messageText') - .text(msg.message) + .text(breakline.trim()) + counterBreaklines++ + } + const offsetLineCounter = counterBreaklines-1 + const totalOffset = offsetLineCounter * breaklineOffset let textWidth = (textElem._groups || textElem)[0][0].getBBox().width let line if (startx === stopx) { if (conf.rightAngles) { - line = g.append('path').attr('d', `M ${startx},${verticalPos} H ${startx + (conf.width / 2)} V ${verticalPos + 25} H ${startx}`) + line = g.append('path').attr('d', `M ${startx},${verticalPos + totalOffset} H ${startx + (conf.width / 2)} V ${verticalPos + 25 + totalOffset} H ${startx}`) } else { line = g.append('path') - .attr('d', 'M ' + startx + ',' + verticalPos + ' C ' + (startx + 60) + ',' + (verticalPos - 10) + ' ' + (startx + 60) + ',' + - (verticalPos + 30) + ' ' + startx + ',' + (verticalPos + 20)) + .attr('d', 'M ' + startx + ',' + (verticalPos + totalOffset) + ' C ' + (startx + 60) + ',' + (verticalPos - 10 + totalOffset) + ' ' + (startx + 60) + ',' + + (verticalPos + 30 + totalOffset) + ' ' + startx + ',' + (verticalPos + 20 + totalOffset)) } - bounds.bumpVerticalPos(30) + bounds.bumpVerticalPos(30+totalOffset) const dx = Math.max(textWidth / 2, 100) - bounds.insert(startx - dx, bounds.getVerticalPos() - 10, stopx + dx, bounds.getVerticalPos()) + bounds.insert(startx - dx, bounds.getVerticalPos() - 10 + totalOffset, stopx + dx, bounds.getVerticalPos() + totalOffset) } else { line = g.append('line') line.attr('x1', startx) line.attr('y1', verticalPos) line.attr('x2', stopx) line.attr('y2', verticalPos) - bounds.insert(startx, bounds.getVerticalPos() - 10, stopx, bounds.getVerticalPos()) + bounds.insert(startx, bounds.getVerticalPos() - 10 + totalOffset, stopx, bounds.getVerticalPos()) + totalOffset } // Make an SVG Container // Draw the line From c6efddee87135f7451d2dacafe585300165915a5 Mon Sep 17 00:00:00 2001 From: Eduardas Michelsonas Date: Wed, 28 Aug 2019 20:13:37 +0200 Subject: [PATCH 2/2] #755 lint fixes --- src/diagrams/sequence/sequenceRenderer.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/diagrams/sequence/sequenceRenderer.js b/src/diagrams/sequence/sequenceRenderer.js index b1282fbea..7c18d314f 100644 --- a/src/diagrams/sequence/sequenceRenderer.js +++ b/src/diagrams/sequence/sequenceRenderer.js @@ -217,14 +217,14 @@ const drawMessage = function (elem, startx, stopx, verticalPos, msg, sequenceInd const breaklines = msg.message.split(//ig) for (const breakline of breaklines) { textElem = g.append('text') // text label for the x axis - .attr('x', txtCenter) - .attr('y', verticalPos - 7 + counterBreaklines * breaklineOffset) - .style('text-anchor', 'middle') - .attr('class', 'messageText') - .text(breakline.trim()) + .attr('x', txtCenter) + .attr('y', verticalPos - 7 + counterBreaklines * breaklineOffset) + .style('text-anchor', 'middle') + .attr('class', 'messageText') + .text(breakline.trim()) counterBreaklines++ } - const offsetLineCounter = counterBreaklines-1 + const offsetLineCounter = counterBreaklines - 1 const totalOffset = offsetLineCounter * breaklineOffset let textWidth = (textElem._groups || textElem)[0][0].getBBox().width @@ -239,7 +239,7 @@ const drawMessage = function (elem, startx, stopx, verticalPos, msg, sequenceInd (verticalPos + 30 + totalOffset) + ' ' + startx + ',' + (verticalPos + 20 + totalOffset)) } - bounds.bumpVerticalPos(30+totalOffset) + bounds.bumpVerticalPos(30 + totalOffset) const dx = Math.max(textWidth / 2, 100) bounds.insert(startx - dx, bounds.getVerticalPos() - 10 + totalOffset, stopx + dx, bounds.getVerticalPos() + totalOffset) } else { @@ -248,7 +248,7 @@ const drawMessage = function (elem, startx, stopx, verticalPos, msg, sequenceInd line.attr('y1', verticalPos) line.attr('x2', stopx) line.attr('y2', verticalPos) - bounds.insert(startx, bounds.getVerticalPos() - 10 + totalOffset, stopx, bounds.getVerticalPos()) + totalOffset + bounds.insert(startx, bounds.getVerticalPos() - 10 + totalOffset, stopx, bounds.getVerticalPos() + totalOffset) } // Make an SVG Container // Draw the line