Skip to content

Commit 6f09f83

Browse files
authored
Merge pull request #94 from highcharts-for-python/develop
PR for v.1.3.5
2 parents bd673ca + 99069c9 commit 6f09f83

File tree

4 files changed

+49
-12
lines changed

4 files changed

+49
-12
lines changed

CHANGES.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11

2+
Release 1.3.5
3+
=========================================
4+
5+
* **BUGFIX:** Fixed validation of style properties in the ``Legend`` class (#93).
6+
7+
---------------------
8+
9+
210
Release 1.3.4
311
=========================================
412

highcharts_core/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.3.4'
1+
__version__ = '1.3.5'

highcharts_core/options/legend/__init__.py

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -319,18 +319,24 @@ def floating(self, value):
319319
self._floating = bool(value)
320320

321321
@property
322-
def item_checkbox_style(self) -> Optional[str]:
322+
def item_checkbox_style(self) -> Optional[str | dict]:
323323
"""Default styling for the checkbox next to a legend item when
324324
:meth:`Legend.show_checkbox` is ``True``. Defaults to:
325325
``'{"width": "13px", "height": "13px", "position":"absolute"}'``.
326326
327-
:rtype: :class:`str <python:str>` or :obj:`None <python:None>`
327+
:rtype: :class:`str <python:str>` or :class:`dict <python:dict>` or
328+
:obj:`None <python:None>`
328329
"""
329330
return self._item_checkbox_style
330331

331332
@item_checkbox_style.setter
332333
def item_checkbox_style(self, value):
333-
self._item_checkbox_style = validators.string(value, allow_empty = True)
334+
try:
335+
self._item_checkbox_style = validators.dict(value, allow_empty = True)
336+
except (ValueError, TypeError):
337+
self._item_checkbox_style = validators.string(value,
338+
allow_empty = True,
339+
coerce_value = True)
334340

335341
@property
336342
def item_distance(self) -> Optional[int | float | Decimal]:
@@ -348,7 +354,7 @@ def item_distance(self, value):
348354
minimum = 0)
349355

350356
@property
351-
def item_hidden_style(self) -> Optional[str]:
357+
def item_hidden_style(self) -> Optional[str | dict]:
352358
"""Default styling for the legend item when the corresponding series or data
353359
point is hidden. Defaults to:
354360
``'{"color": "#cccccc"}'``.
@@ -367,10 +373,15 @@ def item_hidden_style(self) -> Optional[str]:
367373

368374
@item_hidden_style.setter
369375
def item_hidden_style(self, value):
370-
self._item_hidden_style = validators.string(value, allow_empty = True)
376+
try:
377+
self._item_hidden_style = validators.dict(value, allow_empty = True)
378+
except (ValueError, TypeError):
379+
self._item_hidden_style = validators.string(value,
380+
allow_empty = True,
381+
coerce_value = True)
371382

372383
@property
373-
def item_hover_style(self) -> Optional[str]:
384+
def item_hover_style(self) -> Optional[str | dict]:
374385
"""Default styling for the legend item when the corresponding series or data
375386
point is in a hover state. Defaults to:
376387
``'{"color": "#000000"}'``.
@@ -383,13 +394,19 @@ def item_hover_style(self) -> Optional[str]:
383394
384395
Properties are inherited from :meth:`Legend.style` unless overridden here.
385396
386-
:rtype: :class:`str <python:str>` or :obj:`None <python:None>`
397+
:rtype: :class:`str <python:str>` or :class:`dict <python:dict>` or
398+
:obj:`None <python:None>`
387399
"""
388400
return self._item_hover_style
389401

390402
@item_hover_style.setter
391403
def item_hover_style(self, value):
392-
self._item_hover_style = validators.string(value, allow_empty = True)
404+
try:
405+
self._item_hover_style = validators.dict(value, allow_empty = True)
406+
except (ValueError, TypeError):
407+
self._item_hover_style = validators.string(value,
408+
allow_empty = True,
409+
coerce_value = True)
393410

394411
@property
395412
def item_margin_bottom(self) -> Optional[int | float | Decimal]:
@@ -422,9 +439,9 @@ def item_margin_top(self, value):
422439
minimum = 0)
423440

424441
@property
425-
def item_style(self) -> Optional[str]:
442+
def item_style(self) -> Optional[str | dict]:
426443
"""Default styling for each legend item. Defaults to:
427-
``'{"color": "#333333", "cursor": "pointer", "fontSize": "12px", "fontWeight": "bold", "textOverflow": "ellipsis"}'``.
444+
``{"color": "#333333", "cursor": "pointer", "fontSize": "12px", "fontWeight": "bold", "textOverflow": "ellipsis"}``.
428445
429446
.. warning::
430447
@@ -442,7 +459,12 @@ def item_style(self) -> Optional[str]:
442459

443460
@item_style.setter
444461
def item_style(self, value):
445-
self._item_style = validators.string(value, allow_empty = True)
462+
try:
463+
self._item_style = validators.dict(value, allow_empty = True)
464+
except (ValueError, TypeError):
465+
self._item_style = validators.string(value,
466+
allow_empty = True,
467+
coerce_value = True)
446468

447469
@property
448470
def item_width(self) -> Optional[int | float | Decimal]:

tests/options/legend/test_legend.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@
5959
'x': 0,
6060
'y': 0
6161
}, None),
62+
({
63+
'item_style': {
64+
'color': '#5f5e5e',
65+
'fontFamily': 'Roboto',
66+
'fontSize': '12px'
67+
}
68+
}, None),
6269
]
6370

6471

0 commit comments

Comments
 (0)