Skip to content

Commit 8b7b54e

Browse files
authored
Merge pull request #170 from highcharts-for-python/develop
RC v.1.7.1. Closes #169
2 parents 8ddc0fe + 056d34b commit 8b7b54e

File tree

4 files changed

+43
-1
lines changed

4 files changed

+43
-1
lines changed

CHANGES.rst

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

2+
Release 1.7.1
3+
=========================================
4+
5+
* **BUGFIX:** Fixed data collection roundtrip via ``.to_json()`` / ``.from_json()`` (#169).
6+
7+
--------------------
8+
29
Release 1.7.0
310
=========================================
411

highcharts_core/__version__.py

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

highcharts_core/options/series/data/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ def from_array(cls, value):
704704

705705
if checkers.is_type(value, 'DataPointCollection'):
706706
return value
707+
elif isinstance(value, dict) and 'dataPoints' in value:
708+
return cls.from_list(value['dataPoints'])
707709

708710
return cls.from_list(value)
709711

tests/options/series/data/test_cartesian.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,3 +1417,36 @@ def test_CartesianValueData_to_array(input_array, set_props, expected_type, expe
14171417

14181418
if expected_type == list:
14191419
assert results == expected
1420+
1421+
1422+
def test_BugFix_forum192819():
1423+
from highcharts_core import highcharts
1424+
import pandas as pd
1425+
import numpy as np
1426+
1427+
dates = [
1428+
"30/04/2024",
1429+
"30/04/2024",
1430+
"26/04/2024",
1431+
"12/04/2024",
1432+
"31/03/2024",
1433+
"31/03/2024",
1434+
"29/03/2024",
1435+
"15/03/2024",
1436+
"05/03/2024",
1437+
]
1438+
amounts = 100 + np.random.normal(loc=100, scale=10, size=len(dates))
1439+
1440+
df = pd.DataFrame([{"date": x, "amount": y} for x, y in zip(dates, amounts)])
1441+
df["date"] = pd.to_datetime(df["date"], format="%d/%m/%Y")
1442+
df["milliseconds"] = (df["date"] - pd.Timestamp("1970-01-01")) // pd.Timedelta("1ms")
1443+
1444+
my_chart = highcharts.Chart.from_pandas(
1445+
df, property_map={"x": "milliseconds", "y": "amount"}, series_type="line"
1446+
)
1447+
1448+
as_json = my_chart.to_json()
1449+
assert as_json is not None
1450+
1451+
my_new_chart = highcharts.Chart.from_json(as_json)
1452+
assert my_new_chart is not None

0 commit comments

Comments
 (0)