Skip to content

Commit 7105b57

Browse files
authored
Merge pull request #83 from highcharts-for-python/develop
PR for v.1.3.1
2 parents c21bb37 + 0280157 commit 7105b57

File tree

14 files changed

+126
-40
lines changed

14 files changed

+126
-40
lines changed

CHANGES.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2+
Release 1.3.1
3+
=========================================
4+
5+
* **BUGFIX:** Fixed incorrect ``style`` property deserialization in certain places (#82).
6+
7+
---------------------
8+
19
Release 1.3.0
210
=========================================
311

highcharts_core/__version__.py

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

highcharts_core/global_options/language/navigation.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,16 +1236,22 @@ def stroke_width(self, value):
12361236
self._stroke_width = validators.string(value, allow_empty = True)
12371237

12381238
@property
1239-
def style(self) -> Optional[str]:
1239+
def style(self) -> Optional[str | dict]:
12401240
"""Defaults to ``'Style``.
12411241
1242-
:rtype: :class:`str <python:str>` or :obj:`None <python:None>`
1242+
:rtype: :class:`str <python:str>` or :class:`dict <python:dict>` or
1243+
:obj:`None <python:None>`
12431244
"""
12441245
return self._style
12451246

12461247
@style.setter
12471248
def style(self, value):
1248-
self._style = validators.string(value, allow_empty = True, coerce_value = True)
1249+
try:
1250+
self._style = validators.dict(value, allow_empty = True)
1251+
except (ValueError, TypeError):
1252+
self._style = validators.string(value,
1253+
allow_empty = True,
1254+
coerce_value = True)
12491255

12501256
@property
12511257
def time_cycles(self) -> Optional[str]:

highcharts_core/options/annotations/label_options.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ def shape(self, value):
456456
self._shape = value
457457

458458
@property
459-
def style(self) -> Optional[str]:
459+
def style(self) -> Optional[str | dict]:
460460
"""CSS styling to apply to the annotation's label.
461461
462462
:rtype: :class:`str` or :obj:`None <python:None>`
@@ -465,7 +465,12 @@ def style(self) -> Optional[str]:
465465

466466
@style.setter
467467
def style(self, value):
468-
self._style = validators.string(value, allow_empty = True, coerce_value = True)
468+
try:
469+
self._style = validators.dict(value, allow_empty = True)
470+
except (ValueError, TypeError):
471+
self._style = validators.string(value,
472+
allow_empty = True,
473+
coerce_value = True)
469474

470475
@property
471476
def text(self) -> Optional[str]:

highcharts_core/options/axes/labels.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,9 @@ def step(self, value):
446446
minimum = 0)
447447

448448
@property
449-
def style(self) -> Optional[str]:
450-
"""CSS styling to apply to the axis label. Defaults to :obj:`None <python:None>`.
449+
def style(self) -> Optional[str | dict]:
450+
"""CSS styling to apply to the axis label. Defaults to
451+
:obj:`None <python:None>`.
451452
452453
.. hint::
453454
@@ -457,15 +458,19 @@ def style(self) -> Optional[str]:
457458
458459
Use ``"textOverflow: 'one'"`` to prevent ellipsis (three dots).
459460
460-
:rtype: :class:`str` or :obj:`None <python:None>`
461+
:rtype: :class:`str <python:str>` or :class:`dict <python:dict>` or
462+
:obj:`None <python:None>`
461463
"""
462464
return self._style
463465

464466
@style.setter
465467
def style(self, value):
466-
self._style = validators.string(value,
467-
allow_empty = True,
468-
coerce_value = True)
468+
try:
469+
self._style = validators.dict(value, allow_empty = True)
470+
except (ValueError, TypeError):
471+
self._style = validators.string(value,
472+
allow_empty = True,
473+
coerce_value = True)
469474

470475
@property
471476
def use_html(self) -> Optional[bool]:
@@ -653,7 +658,7 @@ def rotation(self, value):
653658
minimum = 0)
654659

655660
@property
656-
def style(self) -> Optional[str]:
661+
def style(self) -> Optional[str | dict]:
657662
"""CSS styling to apply to the label. Defaults to :obj:`None <python:None>`.
658663
659664
:rtype: :class:`str` or :obj:`None <python:None>`
@@ -662,9 +667,12 @@ def style(self) -> Optional[str]:
662667

663668
@style.setter
664669
def style(self, value):
665-
self._style = validators.string(value,
666-
allow_empty = True,
667-
coerce_value = True)
670+
try:
671+
self._style = validators.dict(value, allow_empty = True)
672+
except (ValueError, TypeError):
673+
self._style = validators.string(value,
674+
allow_empty = True,
675+
coerce_value = True)
668676

669677
@property
670678
def text(self) -> Optional[str]:

highcharts_core/options/axes/title.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def skew_3d(self, value):
197197
self._skew_3d = bool(value)
198198

199199
@property
200-
def style(self) -> Optional[str]:
200+
def style(self) -> Optional[str | dict]:
201201
"""CSS styling to apply to the title. Defaults to :obj:`None <python:None>`.
202202
203203
.. hint::
@@ -210,13 +210,19 @@ def style(self) -> Optional[str]:
210210
* Setting ``"whiteSpace: 'nowrap'"`` in the ``style``
211211
* Setting an explicit :meth:`AxisTitle.width`
212212
213-
:rtype: :class:`str` or :obj:`None <python:None>`
213+
:rtype: :class:`str <python:str>` or :class:`dict <python:dict>` or
214+
:obj:`None <python:None>`
214215
"""
215216
return self._style
216217

217218
@style.setter
218219
def style(self, value):
219-
self._style = validators.string(value, allow_empty = True, coerce_value = True)
220+
try:
221+
self._style = validators.dict(value, allow_empty = True)
222+
except (ValueError, TypeError):
223+
self._style = validators.string(value,
224+
allow_empty = True,
225+
coerce_value = True)
220226

221227
@property
222228
def text(self) -> Optional[str | constants.EnforcedNullType]:

highcharts_core/options/chart/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,7 @@ def spacing_top(self, value):
11921192
self._spacing_top = validators.numeric(value, allow_empty = True)
11931193

11941194
@property
1195-
def style(self) -> Optional[str]:
1195+
def style(self) -> Optional[str | dict]:
11961196
"""Additional CSS styles to apply inline to the container div.
11971197
11981198
Defaults to ``'{"fontFamily": "\"Lucida Grande\", \"Lucida Sans Unicode\", Verdana, Arial, Helvetica, sans-serif","fontSize":"12px"}'``.
@@ -1202,13 +1202,19 @@ def style(self) -> Optional[str]:
12021202
Since the default font styles are applied in the renderer, it is ignorant of the
12031203
individual chart options and must be set globally.
12041204
1205-
:rtype: :class:`str` or :obj:`None <python:None>`
1205+
:rtype: :class:`str <python:str>` or :class:`dict <python:dict>` or
1206+
:obj:`None <python:None>`
12061207
"""
12071208
return self._style
12081209

12091210
@style.setter
12101211
def style(self, value):
1211-
self._style = validators.string(value, allow_empty = True, coerce_value = True)
1212+
try:
1213+
self._style = validators.dict(value, allow_empty = True)
1214+
except (ValueError, TypeError):
1215+
self._style = validators.string(value,
1216+
allow_empty = True,
1217+
coerce_value = True)
12121218

12131219
@property
12141220
def styled_mode(self) -> Optional[bool]:

highcharts_core/options/legend/bubble_legend.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,22 @@ def formatter(self, value):
138138
self._formatter = value
139139

140140
@property
141-
def style(self) -> Optional[str]:
141+
def style(self) -> Optional[str | dict]:
142142
"""CSS styling to apply to the data labels.
143143
144-
:rtype: :class:`str` or :obj:`None <python:None>`
144+
:rtype: :class:`str <python:str>` or :class:`dict <python:dict>` or
145+
:obj:`None <python:None>`
145146
"""
146147
return self._style
147148

148149
@style.setter
149150
def style(self, value):
150-
self._style = validators.string(value, allow_empty = True, coerce_value = True)
151+
try:
152+
self._style = validators.dict(value, allow_empty = True)
153+
except (ValueError, TypeError):
154+
self._style = validators.string(value,
155+
allow_empty = True,
156+
coerce_value = True)
151157

152158
@property
153159
def x(self) -> Optional[int]:

highcharts_core/options/legend/navigation.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,22 @@ def inactive_color(self, value):
123123
self._inactive_color = utility_functions.validate_color(value)
124124

125125
@property
126-
def style(self) -> Optional[str]:
126+
def style(self) -> Optional[str | dict]:
127127
"""CSS styling to apply to the legend page navigation.
128128
129-
:rtype: :class:`str` or :obj:`None <python:None>`
129+
:rtype: :class:`str <python:str>` or :class:`dict <python:dict>` or
130+
:obj:`None <python:None>`
130131
"""
131132
return self._style
132133

133134
@style.setter
134135
def style(self, value):
135-
self._style = validators.string(value, allow_empty = True, coerce_value = True)
136+
try:
137+
self._style = validators.dict(value, allow_empty = True)
138+
except (ValueError, TypeError):
139+
self._style = validators.string(value,
140+
allow_empty = True,
141+
coerce_value = True)
136142

137143
@classmethod
138144
def _get_kwargs_from_dict(cls, as_dict):

highcharts_core/options/legend/title.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,23 @@ def __init__(self, **kwargs):
1717
self.text = kwargs.get('text', None)
1818

1919
@property
20-
def style(self) -> Optional[str]:
20+
def style(self) -> Optional[str | dict]:
2121
"""CSS styling to apply to the title. Defaults to
22-
``'{constants.DEFAULT_LEGEND.get('title', {}).get('style')}'``.
22+
``'{"fontSize": "0.75em", "fontWeight": "bold"}'``.
2323
24-
:rtype: :class:`str` or :obj:`None <python:None>`
24+
:rtype: :class:`str <python:str>` or :class:`dict <python:dict>` or
25+
:obj:`None <python:None>`
2526
"""
2627
return self._style
2728

2829
@style.setter
2930
def style(self, value):
30-
self._style = validators.string(value, allow_empty = True, coerce_value = True)
31+
try:
32+
self._style = validators.dict(value, allow_empty = True)
33+
except (ValueError, TypeError):
34+
self._style = validators.string(value,
35+
allow_empty = True,
36+
coerce_value = True)
3137

3238
@property
3339
def text(self) -> Optional[str]:

0 commit comments

Comments
 (0)