From 89ade178ba2c38bab2dadb457ecbfcceb438a447 Mon Sep 17 00:00:00 2001 From: mingrammer Date: Sun, 23 Feb 2020 13:37:13 +0900 Subject: [PATCH] feat: support multi-line labels --- diagrams/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/diagrams/__init__.py b/diagrams/__init__.py index 02e75c4a..e240748c 100644 --- a/diagrams/__init__.py +++ b/diagrams/__init__.py @@ -260,6 +260,8 @@ class Node: _icon_dir = None _icon = None + _height = 1.9 + def __init__(self, label: str = ""): """Node represents a system component. @@ -272,9 +274,11 @@ class Node: # fmt: off # If a node has an icon, increase the height slightly to avoid # that label being spanned between icon image and white space. + # Increase the height by the number of new lines included in the label. + padding = 0.4 * (label.count('\n')) self.attrs = { "shape": "none", - "height": "1.9", + "height": str(self._height + padding), "image": self._load_icon(), } if self._icon else {} # fmt: on