Skip to content

Commit d576a06

Browse files
committed
Added SankeyOptions.node_alignment support
1 parent 281ca27 commit d576a06

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

highcharts_core/options/plot_options/sankey.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ class SankeyOptions(DependencyWheelOptions):
3535
"""
3636
def __init__(self, **kwargs):
3737
self._link_color_mode = None
38+
self._node_alignment = None
3839

3940
self.link_color_mode = kwargs.get('link_color_mode', None)
41+
self.node_alignment = kwargs.get('node_alignment', None)
4042

4143
super().__init__(**kwargs)
4244

@@ -69,7 +71,39 @@ def link_color_mode(self, value):
6971
f'link_color_mode expects a value of either "from", '
7072
f'"gradient", or "to". Received "{value}"')
7173
self._link_color_mode = value
72-
74+
75+
@property
76+
def node_alignment(self) -> Optional[str]:
77+
"""Determines on which side of the chart the nodes are to be aligned.
78+
79+
Accepts:
80+
81+
* ``'top'``
82+
* ``'center'``
83+
* ``'bottom'``
84+
85+
.. note::
86+
87+
When the chart is inverted, ``'top'`` aligns to the left and
88+
``'bottom'`` to the right.
89+
90+
:rtype: :class:`str <python:str>` or :obj:`None <python:None>`
91+
"""
92+
return self._node_alignment
93+
94+
@node_alignment.setter
95+
def node_alignment(self, value):
96+
if not value:
97+
self._node_alignment = None
98+
else:
99+
value = validators.string(value)
100+
value = value.lower()
101+
if value not in ['top', 'center', 'bottom']:
102+
raise errors.HighchartsValueError(f'node_alignment expects a value'
103+
f'of either "top", "center", or '
104+
f'"bottom". Received "{value}"')
105+
self._node_alignment = value
106+
73107
@classmethod
74108
def _get_kwargs_from_dict(cls, as_dict):
75109
kwargs = {
@@ -124,13 +158,15 @@ def _get_kwargs_from_dict(cls, as_dict):
124158
'start_angle': as_dict.get('startAngle', None),
125159

126160
'link_color_mode': as_dict.get('linkColorMode', None),
161+
'node_alignment': as_dict.get('nodeAlignment', None),
127162
}
128163

129164
return kwargs
130165

131166
def _to_untrimmed_dict(self, in_cls = None) -> dict:
132167
untrimmed = {
133168
'linkColorMode': self.link_color_mode,
169+
'nodeAlignment': self.node_alignment,
134170
}
135171
parent_as_dict = super()._to_untrimmed_dict(in_cls = in_cls)
136172

highcharts_core/options/series/sankey.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ def _get_kwargs_from_dict(cls, as_dict):
179179
'start_angle': as_dict.get('startAngle', None),
180180

181181
'link_color_mode': as_dict.get('linkColorMode', None),
182+
'node_alignment': as_dict.get('nodeAlignment', None),
182183

183184
'nodes': as_dict.get('nodes', None),
184185
}

0 commit comments

Comments
 (0)