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
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@

Release 1.7.1
=========================================

* **BUGFIX:** Fixed data collection roundtrip via ``.to_json()`` / ``.from_json()`` (#169).

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

Release 1.7.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.7.0'
__version__ = '1.7.1'
2 changes: 2 additions & 0 deletions highcharts_core/options/series/data/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,8 @@ def from_array(cls, value):

if checkers.is_type(value, 'DataPointCollection'):
return value
elif isinstance(value, dict) and 'dataPoints' in value:
return cls.from_list(value['dataPoints'])

return cls.from_list(value)

Expand Down
33 changes: 33 additions & 0 deletions tests/options/series/data/test_cartesian.py
Original file line number Diff line number Diff line change
Expand Up @@ -1417,3 +1417,36 @@ def test_CartesianValueData_to_array(input_array, set_props, expected_type, expe

if expected_type == list:
assert results == expected


def test_BugFix_forum192819():
from highcharts_core import highcharts
import pandas as pd
import numpy as np

dates = [
"30/04/2024",
"30/04/2024",
"26/04/2024",
"12/04/2024",
"31/03/2024",
"31/03/2024",
"29/03/2024",
"15/03/2024",
"05/03/2024",
]
amounts = 100 + np.random.normal(loc=100, scale=10, size=len(dates))

df = pd.DataFrame([{"date": x, "amount": y} for x, y in zip(dates, amounts)])
df["date"] = pd.to_datetime(df["date"], format="%d/%m/%Y")
df["milliseconds"] = (df["date"] - pd.Timestamp("1970-01-01")) // pd.Timedelta("1ms")

my_chart = highcharts.Chart.from_pandas(
df, property_map={"x": "milliseconds", "y": "amount"}, series_type="line"
)

as_json = my_chart.to_json()
assert as_json is not None

my_new_chart = highcharts.Chart.from_json(as_json)
assert my_new_chart is not None