Skip to content

Commit 31caf35

Browse files
committed
Added ColorAxis.height and ColorAxis.width properties.
1 parent f3fd53c commit 31caf35

File tree

1 file changed

+58
-2
lines changed

1 file changed

+58
-2
lines changed

highcharts_core/options/axes/color_axis.py

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,27 @@ class ColorAxis(GenericAxis):
5555
def __init__(self, **kwargs):
5656
self._data_class_color = None
5757
self._data_classes = None
58+
self._height = None
5859
self._layout = None
5960
self._line_color = None
6061
self._marker = None
6162
self._max_color = None
6263
self._min_color = None
6364
self._show_in_legend = None
6465
self._stops = None
66+
self._width = None
6567

6668
self.data_class_color = kwargs.get('data_class_color', None)
6769
self.data_classes = kwargs.get('data_classes', None)
70+
self.height = kwargs.get('height', None)
6871
self.layout = kwargs.get('layout', None)
6972
self.line_color = kwargs.get('line_color', None)
7073
self.marker = kwargs.get('marker', None)
7174
self.max_color = kwargs.get('max_color', None)
7275
self.min_color = kwargs.get('min_color', None)
7376
self.show_in_legend = kwargs.get('show_in_legend', None)
7477
self.stops = kwargs.get('stops', None)
78+
self.width = kwargs.get('width', None)
7579

7680
super().__init__(**kwargs)
7781

@@ -118,6 +122,30 @@ def data_classes(self) -> Optional[List[DataClass]]:
118122
def data_classes(self, value):
119123
self._data_classes = value
120124

125+
@property
126+
def height(self) -> Optional[str | int | float | Decimal]:
127+
"""The height of the color axis, expressed either in pixels or as a
128+
percentage of the total plot height. Defaults to
129+
:obj:`None <python:None>`.
130+
131+
:rtype: numeric or :class:`str <python:str>` or :obj:`None <python:None>`
132+
"""
133+
return self._height
134+
135+
@height.setter
136+
def height(self, value):
137+
if value is None:
138+
self._height = None
139+
else:
140+
try:
141+
value = validators.string(value)
142+
if "%" not in value:
143+
raise ValueError
144+
except (TypeError, ValueError):
145+
value = validators.numeric(value, minimum=0)
146+
147+
self._height = value
148+
121149
@property
122150
def layout(self) -> Optional[str]:
123151
"""The layout of the color axis. Defaults to :obj:`None <python:None>`.
@@ -273,6 +301,30 @@ def stops(self, value):
273301

274302
self._stops = processed_items
275303

304+
@property
305+
def width(self) -> Optional[str | int | float | Decimal]:
306+
"""The width of the color axis, expressed either in
307+
pixels or as a percentage of the total plot width. Defaults to
308+
:obj:`None <python:None>`.
309+
310+
:rtype: numeric or :class:`str <python:str>` or :obj:`None <python:None>`
311+
"""
312+
return self._width
313+
314+
@width.setter
315+
def width(self, value):
316+
if value is None:
317+
self._width = None
318+
else:
319+
try:
320+
value = validators.string(value)
321+
if "%" not in value:
322+
raise ValueError
323+
except (TypeError, ValueError):
324+
value = validators.numeric(value, minimum=0)
325+
326+
self._width = value
327+
276328
@classmethod
277329
def _get_kwargs_from_dict(cls, as_dict):
278330
kwargs = {
@@ -330,13 +382,15 @@ def _get_kwargs_from_dict(cls, as_dict):
330382

331383
'data_class_color': as_dict.get('dataClassColor', None),
332384
'data_classes': as_dict.get('dataClasses', None),
385+
'height': as_dict.get('height', None),
333386
'layout': as_dict.get('layout', None),
334387
'line_color': as_dict.get('lineColor', None),
335388
'marker': as_dict.get('marker', None),
336389
'max_color': as_dict.get('maxColor', None),
337390
'min_color': as_dict.get('minColor', None),
338391
'show_in_legend': as_dict.get('showInLegend', None),
339-
'stops': as_dict.get('stops', None)
392+
'stops': as_dict.get('stops', None),
393+
'width': as_dict.get('width', None),
340394
}
341395

342396
return kwargs
@@ -397,13 +451,15 @@ def _to_untrimmed_dict(self, in_cls = None) -> dict:
397451

398452
'dataClassColor': self.data_class_color,
399453
'dataClasses': self.data_classes,
454+
'height': self.height,
400455
'layout': self.layout,
401456
'lineColor': self.line_color,
402457
'marker': self.marker,
403458
'maxColor': self.max_color,
404459
'minColor': self.min_color,
405460
'showInLegend': self.show_in_legend,
406-
'stops': self.stops
461+
'stops': self.stops,
462+
'width': self.width,
407463
}
408464

409465
return untrimmed

0 commit comments

Comments
 (0)