mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-11-16 18:54:12 +01:00
Fix for interface rendering and positioning
This commit is contained in:
@@ -54,6 +54,8 @@
|
|||||||
Customer "1" --> "*" Ticket
|
Customer "1" --> "*" Ticket
|
||||||
Student "1" --> "1..*" Course
|
Student "1" --> "1..*" Course
|
||||||
Galaxy --> "many" Star : Contains
|
Galaxy --> "many" Star : Contains
|
||||||
|
<<interface>> Customer
|
||||||
|
<<Service>> Galaxy
|
||||||
</div>
|
</div>
|
||||||
<script src="./mermaid.js"></script>
|
<script src="./mermaid.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
@@ -568,9 +568,12 @@ const class_box = (parent, node) => {
|
|||||||
const hasInterface = node.classData.annotations && node.classData.annotations[0];
|
const hasInterface = node.classData.annotations && node.classData.annotations[0];
|
||||||
|
|
||||||
// 1. Create the labels
|
// 1. Create the labels
|
||||||
|
const interfaceLabelText = node.classData.annotations[0]
|
||||||
|
? '<<' + node.classData.annotations[0] + '>>'
|
||||||
|
: '';
|
||||||
const interfaceLabel = labelContainer
|
const interfaceLabel = labelContainer
|
||||||
.node()
|
.node()
|
||||||
.appendChild(createLabel(node.classData.annotations[0], node.labelStyle, true, true));
|
.appendChild(createLabel(interfaceLabelText, node.labelStyle, true, true));
|
||||||
const interfaceBBox = interfaceLabel.getBBox();
|
const interfaceBBox = interfaceLabel.getBBox();
|
||||||
if (node.classData.annotations[0]) {
|
if (node.classData.annotations[0]) {
|
||||||
maxHeight += interfaceBBox.height + rowPadding;
|
maxHeight += interfaceBBox.height + rowPadding;
|
||||||
@@ -614,13 +617,10 @@ const class_box = (parent, node) => {
|
|||||||
|
|
||||||
// position the interface label
|
// position the interface label
|
||||||
if (hasInterface) {
|
if (hasInterface) {
|
||||||
|
let diffX = (maxWidth - interfaceBBox.width) / 2;
|
||||||
select(interfaceLabel).attr(
|
select(interfaceLabel).attr(
|
||||||
'transform',
|
'transform',
|
||||||
'translate( ' +
|
'translate( ' + ((-1 * maxWidth) / 2 + diffX) + ', ' + (-1 * maxHeight) / 2 + ')'
|
||||||
-(maxWidth + node.padding - interfaceBBox.width / 2) / 2 +
|
|
||||||
', ' +
|
|
||||||
(-1 * maxHeight) / 2 +
|
|
||||||
')'
|
|
||||||
);
|
);
|
||||||
verticalPos = interfaceBBox.height + rowPadding;
|
verticalPos = interfaceBBox.height + rowPadding;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user