1- from typing import Optional
1+ from typing import Optional , List
22
33from validator_collection import validators , checkers
44
55from highcharts_core .chart import Chart as ChartBase
66
7- from highcharts_maps import constants , errors , utility_functions
7+ from highcharts_maps import errors , utility_functions
88from highcharts_maps .options import HighchartsOptions , HighchartsMapsOptions
99from highcharts_maps .decorators import validate_types
1010from highcharts_maps .js_literal_functions import serialize_to_js_literal
@@ -29,36 +29,6 @@ def __init__(self, **kwargs):
2929
3030 super ().__init__ (** kwargs )
3131
32- def _jupyter_include_scripts (self ):
33- """Return the JavaScript code that is used to load the Highcharts JS libraries.
34-
35- .. note::
36-
37- Currently includes *all* `Highcharts JS <https://www.highcharts.com/>`_ modules
38- in the HTML. This issue will be addressed when roadmap issue :issue:`2` is
39- released.
40-
41- :rtype: :class:`str <python:str>`
42- """
43- js_str = ''
44- if self .is_maps_chart :
45- for item in constants .MAPS_INCLUDE_LIBS :
46- js_str += utility_functions .jupyter_add_script (item )
47- js_str += """.then(() => {"""
48-
49- for item in constants .MAPS_INCLUDE_LIBS :
50- js_str += """});"""
51-
52- else :
53- for item in constants .INCLUDE_LIBS :
54- js_str += utility_functions .jupyter_add_script (item )
55- js_str += """.then(() => {"""
56-
57- for item in constants .INCLUDE_LIBS :
58- js_str += """});"""
59-
60- return js_str
61-
6232 def _jupyter_javascript (self ,
6333 global_options = None ,
6434 container = None ,
@@ -118,6 +88,25 @@ def _jupyter_javascript(self,
11888
11989 return js_str
12090
91+ def get_required_modules (self , include_extension = False ) -> List [str ]:
92+ """Return the list of URLs from which the Highcharts JavaScript modules
93+ needed to render the chart can be retrieved.
94+
95+ :param include_extension: if ``True``, will return script names with the
96+ ``'.js'`` extension included. Defaults to ``False``.
97+ :type include_extension: :class:`bool <python:bool>`
98+
99+ :rtype: :class:`list <python:list>`
100+ """
101+ initial_scripts = ['highcharts' ]
102+ if self .is_maps_chart :
103+ initial_scripts .extend (['maps/modules/map' ,
104+ 'modules/exporting' ])
105+
106+ scripts = self ._process_required_modules (initial_scripts , include_extension )
107+
108+ return scripts
109+
121110 @property
122111 def is_maps_chart (self ) -> bool :
123112 """If ``True``, indicates that the chart should be rendered as a
0 commit comments