diff --git a/CHANGES.rst b/CHANGES.rst index a25b050..cc9bf3b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,4 +1,14 @@ +Release 1.7.1 +========================================= + +* **BUGFIX:** Fixed the use of an improper constructor when exporting Map charts. +* **ENHANCEMENT:** Bumped requirement to use latest version of Highcharts Core for Python, which + also fixes an export-related serialization error. +* **ENHANCEMENT:** Bumped ``requests`` version number for security patch. + +-------------------- + Release 1.7.0 ========================================= diff --git a/highcharts_maps/__version__.py b/highcharts_maps/__version__.py index 0e1a38d..48c2f6b 100644 --- a/highcharts_maps/__version__.py +++ b/highcharts_maps/__version__.py @@ -1 +1 @@ -__version__ = '1.7.0' +__version__ = '1.7.1' diff --git a/highcharts_maps/chart.py b/highcharts_maps/chart.py index 77b785b..2b95450 100644 --- a/highcharts_maps/chart.py +++ b/highcharts_maps/chart.py @@ -391,7 +391,7 @@ def download_chart(self, :rtype: :class:`bytes ` or :class:`str ` """ if self.is_maps_chart: - constructor = 'Stock' + constructor = 'Map' else: constructor = 'Chart' diff --git a/highcharts_maps/options/series/data/map_data.py b/highcharts_maps/options/series/data/map_data.py index 2f9a1cf..42b1b01 100644 --- a/highcharts_maps/options/series/data/map_data.py +++ b/highcharts_maps/options/series/data/map_data.py @@ -249,9 +249,48 @@ def _to_untrimmed_dict(self, in_cls = None) -> dict: return untrimmed + @staticmethod + def trim_dict(untrimmed: dict, + to_json: bool = False, + context: str = None, + for_export: bool = False) -> dict: + """Remove keys from ``untrimmed`` whose values are :obj:`None ` and + convert values that have ``.to_dict()`` methods. + + :param untrimmed: The :class:`dict ` whose values may still be + :obj:`None ` or Python objects. + :type untrimmed: :class:`dict ` + + :param to_json: If ``True``, will remove all keys from ``untrimmed`` that are not + serializable to JSON. Defaults to ``False``. + :type to_json: :class:`bool ` + + :param context: If provided, will inform the method of the context in which it is + being run which may inform special handling cases (e.g. where empty strings may + be important / allowable). Defaults to :obj:`None `. + :type context: :class:`str ` or :obj:`None ` + + :param for_export: If ``True``, indicates that the method is being run to + produce a JSON for consumption by the export server. Defaults to ``False``. + :type for_export: :class:`bool ` + + :returns: Trimmed :class:`dict ` + :rtype: :class:`dict ` + """ + if not for_export: + return HighchartsMeta.trim_dict(untrimmed = untrimmed, + to_json = to_json, + context = context, + for_export = for_export) + + topology = untrimmed.get('topology', None) + + return topology + def to_json(self, filename = None, - encoding = 'utf-8'): + encoding = 'utf-8', + for_export: bool = False): """Generate a JSON string/byte string representation of the object compatible with the Highcharts JavaScript library. @@ -271,6 +310,10 @@ def to_json(self, to ``'utf-8'``. :type encoding: :class:`str ` + :param for_export: If ``True``, indicates that the method is being run to + produce a JSON for consumption by the export server. Defaults to ``False``. + :type for_export: :class:`bool ` + :returns: A JSON representation of the object compatible with the Highcharts library. :rtype: :class:`str ` or :class:`bytes ` diff --git a/pyproject.toml b/pyproject.toml index 9c86de5..893f5fc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,10 +58,10 @@ classifiers = [ requires-python = ">= 3.10" dependencies = [ - "highcharts-core>=1.7.0", + "highcharts-core>=1.9.3", "esprima>=4.0.1", "validator-collection>=1.5.0", - "requests>=2.31.0", + "requests>=2.32.0", "topojson>=1.5", "geojson>=3.0" ] diff --git a/requirements.dev.txt b/requirements.dev.txt index 886bf4a..9782e17 100644 --- a/requirements.dev.txt +++ b/requirements.dev.txt @@ -14,7 +14,7 @@ Sphinx==6.1.3 sphinx-rtd-theme==1.2.0 sphinx-toolbox>=3.4.0 sphinx-tabs>=3.4.1 -requests==2.31.0 +requests==2.32.0 tox==4.0.0 validator-collection==1.5.0 -highcharts-core>=1.7.0 \ No newline at end of file +highcharts-core>=1.9.3 \ No newline at end of file diff --git a/requirements.travis.txt b/requirements.travis.txt index 886bf4a..9782e17 100644 --- a/requirements.travis.txt +++ b/requirements.travis.txt @@ -14,7 +14,7 @@ Sphinx==6.1.3 sphinx-rtd-theme==1.2.0 sphinx-toolbox>=3.4.0 sphinx-tabs>=3.4.1 -requests==2.31.0 +requests==2.32.0 tox==4.0.0 validator-collection==1.5.0 -highcharts-core>=1.7.0 \ No newline at end of file +highcharts-core>=1.9.3 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index a67175d..df5432c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ esprima==4.0.1 geojson==3.0.1 -requests==2.31.0 +requests==2.32.0 topojson==1.5 validator-collection==1.5.0 -highcharts-core>=1.7.0 \ No newline at end of file +highcharts-core>=1.9.3 \ No newline at end of file