Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR for v.1.4.2 #45

Merged
merged 4 commits into from
Oct 25, 2023
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
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Release 1.4.2
=========================================

* **BUGFIX**: Fixed missing ``.data`` property in ``FlagSeries`` objects (#43 )

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


Release 1.4.1
=========================================
Expand Down
2 changes: 1 addition & 1 deletion highcharts_stock/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.4.1'
__version__ = '1.4.2'
61 changes: 59 additions & 2 deletions highcharts_stock/options/series/flags.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from highcharts_stock.utility_functions import mro__to_untrimmed_dict
from typing import Optional, List

from highcharts_stock.utility_functions import mro__to_untrimmed_dict, is_ndarray

from highcharts_stock.options.series.base import NavigatorIndicatorSeries
from highcharts_stock.options.plot_options.flags import FlagsOptions
from highcharts_stock.options.series.data.single_point import (SingleXData,
SingleXDataCollection)


class FlagsSeries(NavigatorIndicatorSeries, FlagsOptions):
Expand All @@ -15,7 +19,53 @@ class FlagsSeries(NavigatorIndicatorSeries, FlagsOptions):
"""

def __init__(self, **kwargs):
self._data = None

self.data = kwargs.get('data', None)

super().__init__(**kwargs)

@property
def data(self) -> Optional[List[SingleXData] | SingleXDataCollection]:
"""Collection of data that represents the series. Defaults to
:obj:`None <python:None>`.

While the series type returns a collection of :class:`SingleXData` instances
or an :class:`SingleXDataCollection` instance, it accepts as input
two different types of data:

.. tabs::

.. tab:: 1D Collection

.. code-block::

series = FlagSeries()
series.data = [
[1463753252],
[1563753252],
[1663753252]
]

A one-dimensional collection of values, corresponding to the position of
each flag on the x-axis.

.. tab:: Object Collection

A one-dimensional collection of :class:`SingleXData` objects, or objects
coercable.

:rtype: :class:`list <python:list>` of :class:`SingleXData` or
:class:`SingleXDataCollection` or :obj:`None <python:None>`
"""
return self._data

@data.setter
def data(self, value):
if not is_ndarray(value) and not value:
self._data = None
else:
self._data = SingleXData.from_array(value)

@classmethod
def _get_kwargs_from_dict(cls, as_dict):
Expand Down Expand Up @@ -130,11 +180,18 @@ def _get_kwargs_from_dict(cls, as_dict):
'x_axis': as_dict.get('xAxis', None),
'y_axis': as_dict.get('yAxis', None),
'z_index': as_dict.get('zIndex', None),

'data': as_dict.get('data', None),
}

return kwargs

def _to_untrimmed_dict(self, in_cls = None) -> dict:
untrimmed = mro__to_untrimmed_dict(self, in_cls = in_cls) or {}
untrimmed = {
'data': self.data
}
untrimmed_parents = mro__to_untrimmed_dict(self, in_cls = in_cls) or {}
for key in untrimmed_parents:
untrimmed[key] = untrimmed_parents[key]

return untrimmed