Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@

Release 1.3.1
=========================================

* **BUGFIX:** Fixed incorrect ``style`` property deserialization in certain places (#82).

---------------------

Release 1.3.0
=========================================

Expand Down
2 changes: 1 addition & 1 deletion highcharts_core/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.3.0'
__version__ = '1.3.1'
12 changes: 9 additions & 3 deletions highcharts_core/global_options/language/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1236,16 +1236,22 @@ def stroke_width(self, value):
self._stroke_width = validators.string(value, allow_empty = True)

@property
def style(self) -> Optional[str]:
def style(self) -> Optional[str | dict]:
"""Defaults to ``'Style``.

:rtype: :class:`str <python:str>` or :obj:`None <python:None>`
:rtype: :class:`str <python:str>` or :class:`dict <python:dict>` or
:obj:`None <python:None>`
"""
return self._style

@style.setter
def style(self, value):
self._style = validators.string(value, allow_empty = True, coerce_value = True)
try:
self._style = validators.dict(value, allow_empty = True)
except (ValueError, TypeError):
self._style = validators.string(value,
allow_empty = True,
coerce_value = True)

@property
def time_cycles(self) -> Optional[str]:
Expand Down
9 changes: 7 additions & 2 deletions highcharts_core/options/annotations/label_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ def shape(self, value):
self._shape = value

@property
def style(self) -> Optional[str]:
def style(self) -> Optional[str | dict]:
"""CSS styling to apply to the annotation's label.

:rtype: :class:`str` or :obj:`None <python:None>`
Expand All @@ -465,7 +465,12 @@ def style(self) -> Optional[str]:

@style.setter
def style(self, value):
self._style = validators.string(value, allow_empty = True, coerce_value = True)
try:
self._style = validators.dict(value, allow_empty = True)
except (ValueError, TypeError):
self._style = validators.string(value,
allow_empty = True,
coerce_value = True)

@property
def text(self) -> Optional[str]:
Expand Down
28 changes: 18 additions & 10 deletions highcharts_core/options/axes/labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,9 @@ def step(self, value):
minimum = 0)

@property
def style(self) -> Optional[str]:
"""CSS styling to apply to the axis label. Defaults to :obj:`None <python:None>`.
def style(self) -> Optional[str | dict]:
"""CSS styling to apply to the axis label. Defaults to
:obj:`None <python:None>`.

.. hint::

Expand All @@ -457,15 +458,19 @@ def style(self) -> Optional[str]:

Use ``"textOverflow: 'one'"`` to prevent ellipsis (three dots).

:rtype: :class:`str` or :obj:`None <python:None>`
:rtype: :class:`str <python:str>` or :class:`dict <python:dict>` or
:obj:`None <python:None>`
"""
return self._style

@style.setter
def style(self, value):
self._style = validators.string(value,
allow_empty = True,
coerce_value = True)
try:
self._style = validators.dict(value, allow_empty = True)
except (ValueError, TypeError):
self._style = validators.string(value,
allow_empty = True,
coerce_value = True)

@property
def use_html(self) -> Optional[bool]:
Expand Down Expand Up @@ -653,7 +658,7 @@ def rotation(self, value):
minimum = 0)

@property
def style(self) -> Optional[str]:
def style(self) -> Optional[str | dict]:
"""CSS styling to apply to the label. Defaults to :obj:`None <python:None>`.

:rtype: :class:`str` or :obj:`None <python:None>`
Expand All @@ -662,9 +667,12 @@ def style(self) -> Optional[str]:

@style.setter
def style(self, value):
self._style = validators.string(value,
allow_empty = True,
coerce_value = True)
try:
self._style = validators.dict(value, allow_empty = True)
except (ValueError, TypeError):
self._style = validators.string(value,
allow_empty = True,
coerce_value = True)

@property
def text(self) -> Optional[str]:
Expand Down
12 changes: 9 additions & 3 deletions highcharts_core/options/axes/title.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def skew_3d(self, value):
self._skew_3d = bool(value)

@property
def style(self) -> Optional[str]:
def style(self) -> Optional[str | dict]:
"""CSS styling to apply to the title. Defaults to :obj:`None <python:None>`.

.. hint::
Expand All @@ -210,13 +210,19 @@ def style(self) -> Optional[str]:
* Setting ``"whiteSpace: 'nowrap'"`` in the ``style``
* Setting an explicit :meth:`AxisTitle.width`

:rtype: :class:`str` or :obj:`None <python:None>`
:rtype: :class:`str <python:str>` or :class:`dict <python:dict>` or
:obj:`None <python:None>`
"""
return self._style

@style.setter
def style(self, value):
self._style = validators.string(value, allow_empty = True, coerce_value = True)
try:
self._style = validators.dict(value, allow_empty = True)
except (ValueError, TypeError):
self._style = validators.string(value,
allow_empty = True,
coerce_value = True)

@property
def text(self) -> Optional[str | constants.EnforcedNullType]:
Expand Down
12 changes: 9 additions & 3 deletions highcharts_core/options/chart/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,7 @@ def spacing_top(self, value):
self._spacing_top = validators.numeric(value, allow_empty = True)

@property
def style(self) -> Optional[str]:
def style(self) -> Optional[str | dict]:
"""Additional CSS styles to apply inline to the container div.

Defaults to ``'{"fontFamily": "\"Lucida Grande\", \"Lucida Sans Unicode\", Verdana, Arial, Helvetica, sans-serif","fontSize":"12px"}'``.
Expand All @@ -1202,13 +1202,19 @@ def style(self) -> Optional[str]:
Since the default font styles are applied in the renderer, it is ignorant of the
individual chart options and must be set globally.

:rtype: :class:`str` or :obj:`None <python:None>`
:rtype: :class:`str <python:str>` or :class:`dict <python:dict>` or
:obj:`None <python:None>`
"""
return self._style

@style.setter
def style(self, value):
self._style = validators.string(value, allow_empty = True, coerce_value = True)
try:
self._style = validators.dict(value, allow_empty = True)
except (ValueError, TypeError):
self._style = validators.string(value,
allow_empty = True,
coerce_value = True)

@property
def styled_mode(self) -> Optional[bool]:
Expand Down
12 changes: 9 additions & 3 deletions highcharts_core/options/legend/bubble_legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,22 @@ def formatter(self, value):
self._formatter = value

@property
def style(self) -> Optional[str]:
def style(self) -> Optional[str | dict]:
"""CSS styling to apply to the data labels.
:rtype: :class:`str` or :obj:`None <python:None>`
:rtype: :class:`str <python:str>` or :class:`dict <python:dict>` or
:obj:`None <python:None>`
"""
return self._style

@style.setter
def style(self, value):
self._style = validators.string(value, allow_empty = True, coerce_value = True)
try:
self._style = validators.dict(value, allow_empty = True)
except (ValueError, TypeError):
self._style = validators.string(value,
allow_empty = True,
coerce_value = True)

@property
def x(self) -> Optional[int]:
Expand Down
12 changes: 9 additions & 3 deletions highcharts_core/options/legend/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,22 @@ def inactive_color(self, value):
self._inactive_color = utility_functions.validate_color(value)

@property
def style(self) -> Optional[str]:
def style(self) -> Optional[str | dict]:
"""CSS styling to apply to the legend page navigation.

:rtype: :class:`str` or :obj:`None <python:None>`
:rtype: :class:`str <python:str>` or :class:`dict <python:dict>` or
:obj:`None <python:None>`
"""
return self._style

@style.setter
def style(self, value):
self._style = validators.string(value, allow_empty = True, coerce_value = True)
try:
self._style = validators.dict(value, allow_empty = True)
except (ValueError, TypeError):
self._style = validators.string(value,
allow_empty = True,
coerce_value = True)

@classmethod
def _get_kwargs_from_dict(cls, as_dict):
Expand Down
14 changes: 10 additions & 4 deletions highcharts_core/options/legend/title.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,23 @@ def __init__(self, **kwargs):
self.text = kwargs.get('text', None)

@property
def style(self) -> Optional[str]:
def style(self) -> Optional[str | dict]:
"""CSS styling to apply to the title. Defaults to
``'{constants.DEFAULT_LEGEND.get('title', {}).get('style')}'``.
``'{"fontSize": "0.75em", "fontWeight": "bold"}'``.

:rtype: :class:`str` or :obj:`None <python:None>`
:rtype: :class:`str <python:str>` or :class:`dict <python:dict>` or
:obj:`None <python:None>`
"""
return self._style

@style.setter
def style(self, value):
self._style = validators.string(value, allow_empty = True, coerce_value = True)
try:
self._style = validators.dict(value, allow_empty = True)
except (ValueError, TypeError):
self._style = validators.string(value,
allow_empty = True,
coerce_value = True)

@property
def text(self) -> Optional[str]:
Expand Down
18 changes: 14 additions & 4 deletions highcharts_core/options/loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def hide_duration(self, value):
minimum = 0)

@property
def label_style(self) -> Optional[str]:
def label_style(self) -> Optional[str | dict]:
"""CSS styles applied to the loading label's ``<span>``. Defaults to
``'{"fontWeight": "bold", "position": "relative", "top": "45%"}'``.

Expand All @@ -67,7 +67,12 @@ def label_style(self) -> Optional[str]:

@label_style.setter
def label_style(self, value):
self._label_style = validators.string(value, allow_empty = True)
try:
self._style = validators.dict(value, allow_empty = True)
except (ValueError, TypeError):
self._style = validators.string(value,
allow_empty = True,
coerce_value = True)

@property
def show_duration(self) -> Optional[int]:
Expand All @@ -85,7 +90,7 @@ def show_duration(self, value):
minimum = 0)

@property
def style(self) -> Optional[str]:
def style(self) -> Optional[str | dict]:
"""CSS styles for the loading screen that covers the plot area. Defaults to
``'{"position": "absolute", "backgroundColor": "#ffffff", "opacity": 0.5, "textAlign": "center"}'``.

Expand All @@ -95,7 +100,12 @@ def style(self) -> Optional[str]:

@style.setter
def style(self, value):
self._style = validators.string(value, allow_empty = True, coerce_value = True)
try:
self._style = validators.dict(value, allow_empty = True)
except (ValueError, TypeError):
self._style = validators.string(value,
allow_empty = True,
coerce_value = True)

@classmethod
def _get_kwargs_from_dict(cls, as_dict):
Expand Down
9 changes: 7 additions & 2 deletions highcharts_core/options/no_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def position(self, value):
self._position = value

@property
def style(self) -> Optional[str]:
def style(self) -> Optional[str | dict]:
"""CSS styles to apply to the no-data label.
:rtype: :class:`str <python:str>` or :obj:`None <python:None>`
Expand All @@ -78,7 +78,12 @@ def style(self) -> Optional[str]:

@style.setter
def style(self, value):
self._style = validators.string(value, allow_empty = True, coerce_value = True)
try:
self._style = validators.dict(value, allow_empty = True)
except (ValueError, TypeError):
self._style = validators.string(value,
allow_empty = True,
coerce_value = True)

@property
def use_html(self) -> Optional[bool]:
Expand Down
9 changes: 7 additions & 2 deletions highcharts_core/options/tooltips.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ def stick_on_contact(self, value):
self._stick_on_contact = bool(value)

@property
def style(self) -> Optional[str]:
def style(self) -> Optional[str | dict]:
"""CSS styling to apply to the tooltip.

.. note::
Expand All @@ -795,7 +795,12 @@ def style(self) -> Optional[str]:

@style.setter
def style(self, value):
self._style = validators.string(value, allow_empty = True, coerce_value = True)
try:
self._style = validators.dict(value, allow_empty = True)
except (ValueError, TypeError):
self._style = validators.string(value,
allow_empty = True,
coerce_value = True)

@property
def use_html(self) -> Optional[bool]:
Expand Down
9 changes: 9 additions & 0 deletions tests/options/axes/test_x_axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,16 @@
'top': 340,
'width': 300,
}, None),
# BUG: #82 - dict converted to string
({
'labels': {
'style': {
'color': 'red'
}
}
}, None),
# with GenericAxis and NumericAxis properties

({
'crosshair': {
'className': 'some-class-name',
Expand Down