From fb6a2dd40eb6a81506ce8eed4fc9b3c9e9e6d388 Mon Sep 17 00:00:00 2001 From: Bruno Meneguello <1322552+bkmeneguello@users.noreply.github.com> Date: Wed, 30 Dec 2020 15:08:41 -0300 Subject: [PATCH] Fix Node Cluster "direction", despite it don't work --- diagrams/__init__.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/diagrams/__init__.py b/diagrams/__init__.py index 6ac564f5..669c4347 100644 --- a/diagrams/__init__.py +++ b/diagrams/__init__.py @@ -280,7 +280,7 @@ class Node(_Cluster): _icon_dir = None _icon = None _icon_size = 30 - _direction = "TB" + _direction = "LR" _height = 1.9 # fmt: on @@ -296,6 +296,7 @@ class Node(_Cluster): def __init__( self, label: str = "", + direction: str = None, icon: object = None, icon_size: int = None, **attrs: Dict @@ -303,6 +304,7 @@ class Node(_Cluster): """Node represents a system component. :param label: Node label. + :param direction: Data flow direction. Default is "LR" (left to right). :param icon: Custom icon for tihs cluster. Must be a node class or reference. :param icon_size: The icon size when used as a Cluster. Default is 30. """ @@ -312,6 +314,10 @@ class Node(_Cluster): super().__init__() + if direction: + if not self._validate_direction(direction): + raise ValueError(f'"{direction}" is not a valid direction') + self._direction = direction if icon: _node = icon(_no_init=True) self._icon = _node._icon @@ -356,8 +362,6 @@ class Node(_Cluster): ''.join(f'