Skip to content

Commit de94799

Browse files
authored
Merge pull request #65 from highcharts-for-python/develop
PR for v.1.2.3
2 parents 0e3b262 + 88a802b commit de94799

File tree

7 files changed

+97
-10
lines changed

7 files changed

+97
-10
lines changed

CHANGES.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Release 1.2.3
2+
=========================================
3+
4+
* **BUGFIX:** Fixed error when loading certain Highcharts (JS) scripts in Jupyter context.
5+
* **ENHANCEMENT:** Increased the default timeout for ``Chart.download_chart()`` and related.
6+
7+
------------------
8+
19
Release 1.2.2
210
=========================================
311

highcharts_core/__version__.py

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

highcharts_core/chart.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ def download_chart(self,
411411
filename = None,
412412
auth_user = None,
413413
auth_password = None,
414-
timeout = 0.5,
414+
timeout = 3,
415415
server_instance = None,
416416
**kwargs):
417417
"""Export a downloaded form of the chart using a Highcharts :term:`Export Server`.
@@ -432,7 +432,7 @@ def download_chart(self,
432432
433433
:param timeout: The number of seconds to wait before issuing a timeout error.
434434
The timeout check is passed if bytes have been received on the socket in less
435-
than the ``timeout`` value. Defaults to ``0.5``.
435+
than the ``timeout`` value. Defaults to ``3``.
436436
:type timeout: numeric or :obj:`None <python:None>`
437437
438438
:param server_instance: Provide an already-configured :class:`ExportServer`

highcharts_core/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
try:
2323
MODULE_REQUIREMENTS = json.load(module_requirements)
2424
except AttributeError:
25-
MODULE_REQUIRE = json.loads(module_requirements.read())
25+
MODULE_REQUIREMENTS = json.loads(module_requirements.read())
2626

2727

2828
class EnforcedNullType:

highcharts_core/headless_export.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ def request_chart(self,
621621
filename = None,
622622
auth_user = None,
623623
auth_password = None,
624-
timeout = 0.5,
624+
timeout = 3,
625625
**kwargs):
626626
"""Execute a request against the export server based on the configuration in the
627627
instance.
@@ -642,7 +642,7 @@ def request_chart(self,
642642
643643
:param timeout: The number of seconds to wait before issuing a timeout error.
644644
The timeout check is passed if bytes have been received on the socket in less
645-
than the ``timeout`` value. Defaults to ``0.5``.
645+
than the ``timeout`` value. Defaults to ``3``.
646646
:type timeout: numeric or :obj:`None <python:None>`
647647
648648
.. note::
@@ -782,7 +782,7 @@ def get_chart(cls,
782782
filename = None,
783783
auth_user = None,
784784
auth_password = None,
785-
timeout = 0.5,
785+
timeout = 3,
786786
**kwargs):
787787
"""Produce an exported chart image.
788788
@@ -802,7 +802,7 @@ def get_chart(cls,
802802
803803
:param timeout: The number of seconds to wait before issuing a timeout error.
804804
The timeout check is passed if bytes have been received on the socket in less
805-
than the ``timeout`` value. Defaults to ``0.5``.
805+
than the ``timeout`` value. Defaults to ``3``.
806806
:type timeout: numeric or :obj:`None <python:None>`
807807
808808
.. note::

highcharts_core/metaclasses.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,10 @@ def _process_required_modules(self, scripts = None, include_extension = False) -
6363
"""
6464
if not scripts:
6565
scripts = []
66+
67+
properties = [x[1:] for x in self.__dict__
68+
if x.startswith('_') and hasattr(self, x[1:])]
6669

67-
properties = [x for x in self.__class__.__dict__
68-
if self.__class__.__dict__[x].__class__.__name__ == 'property']
6970
for property_name in properties:
7071
property_value = getattr(self, property_name, None)
7172
if property_value is None:

tests/test_chart.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,81 @@ def test_from_js_literal(input_files, input_filename, expected_filename, as_file
6666
expected_filename,
6767
as_file,
6868
error)
69+
70+
71+
72+
@pytest.mark.parametrize('json_str, expected_modules, error', [
73+
("""{
74+
"chart": {
75+
"type": "column"
76+
},
77+
"colors": null,
78+
"credits": false,
79+
"exporting": {
80+
"scale": 1
81+
},
82+
"series": [{
83+
"baseSeries": 1,
84+
"color": "#434343",
85+
"name": "Pareto",
86+
"tooltip": {
87+
"valueDecimals": 2,
88+
"valueSuffix": "%"
89+
},
90+
"type": "pareto",
91+
"yAxis": 1,
92+
"zIndex": 10
93+
}, {
94+
"color": "#7cb5ec",
95+
"data": [1, 23, 45, 54, 84, 13, 8, 7, 23, 1, 34, 6, 8, 99, 85, 23, 3, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1],
96+
"name": "random-name",
97+
"type": "column",
98+
"zIndex": 2
99+
}],
100+
"title": {
101+
"text": "Random Name Pareto"
102+
},
103+
"tooltip": {
104+
"shared": true
105+
},
106+
"xAxis": {
107+
"categories": ["Something", "Something", "Something", "Something", "Something", "Something", "Hypovolemia", "Something", "Something", "Something", "Something", "Something", "Something", "Something", "Something", "Something", "Something", "Something", "Something", "Something", "Something", "Something", "Something", "Something", "Something", "Something", "Something", "Something", "Something"],
108+
"crosshair": true,
109+
"labels": {
110+
"rotation": 90
111+
}
112+
},
113+
"yAxis": [{
114+
"title": {
115+
"text": "count"
116+
}
117+
}, {
118+
"labels": {
119+
"format": "{value}%"
120+
},
121+
"max": 100,
122+
"maxPadding": 0,
123+
"min": 0,
124+
"minPadding": 0,
125+
"opposite": true,
126+
"title": {
127+
"text": "accum percent"
128+
}
129+
}]
130+
}""", ['highcharts', 'modules/exporting', 'modules/pareto'], None),
131+
])
132+
def test_get_required_modules(json_str, expected_modules, error):
133+
from highcharts_core.options import HighchartsOptions
134+
options = HighchartsOptions.from_json(json_str)
135+
chart = cls.from_options(options)
136+
if not error:
137+
result = chart.get_required_modules()
138+
if expected_modules:
139+
assert len(result) == len(expected_modules)
140+
for item in expected_modules:
141+
assert item in result
142+
else:
143+
assert result is None or len(result) == 0
144+
else:
145+
with pytest.raises(error):
146+
result = chart.get_required_modules()

0 commit comments

Comments
 (0)