Skip to content

Commit 057e0a2

Browse files
committed
Added unit test for #169
1 parent dc4fa8b commit 057e0a2

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

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)