|
11 | 11 | import requests |
12 | 12 | from validator_collection import validators |
13 | 13 |
|
14 | | -from highcharts_core import errors |
| 14 | +from highcharts_core import errors, constants |
15 | 15 | from highcharts_core.decorators import class_sensitive |
16 | 16 | from highcharts_core.metaclasses import HighchartsMeta |
17 | 17 | from highcharts_core.utility_classes.javascript_functions import CallbackFunction |
@@ -531,6 +531,25 @@ def custom_code(self) -> Optional[CallbackFunction]: |
531 | 531 | def custom_code(self, value): |
532 | 532 | self._custom_code = value |
533 | 533 |
|
| 534 | + @classmethod |
| 535 | + def is_export_supported(cls, options) -> bool: |
| 536 | + """Evaluates whether the Highcharts Export Server supports exporting the series types in ``options``. |
| 537 | + |
| 538 | + :rtype: :class:`bool <python:bool>` |
| 539 | + """ |
| 540 | + if not isinstance(options, HighchartsOptions): |
| 541 | + return False |
| 542 | + |
| 543 | + if not options.series: |
| 544 | + return True |
| 545 | + |
| 546 | + series_types = [x.type for x in options.series] |
| 547 | + for item in series_types: |
| 548 | + if item in constants.EXPORT_SERVER_UNSUPPORTED_SERIES_TYPES: |
| 549 | + return False |
| 550 | + |
| 551 | + return True |
| 552 | + |
534 | 553 | @classmethod |
535 | 554 | def _get_kwargs_from_dict(cls, as_dict): |
536 | 555 | url = as_dict.get('url', None) |
@@ -693,6 +712,12 @@ def request_chart(self, |
693 | 712 |
|
694 | 713 | as_json = json.dumps(payload) |
695 | 714 |
|
| 715 | + if not self.is_export_supported(self.options): |
| 716 | + raise errors.HighchartsUnsupportedExportError('The Highcharts Export Server currently only supports ' |
| 717 | + 'exports from Highcharts (Javascript) v.10. You are ' |
| 718 | + 'using a series type introduced in v.11. Sorry, but ' |
| 719 | + 'that functionality is still forthcoming.') |
| 720 | + |
696 | 721 | options_as_json = self.options.to_json() |
697 | 722 | if isinstance(options_as_json, bytes): |
698 | 723 | options_as_str = str(options_as_json, encoding = 'utf-8') |
|
0 commit comments