@@ -87,11 +87,12 @@ def __init__(self, **kwargs):
87
87
self .data_temp = []
88
88
# Data from jsonp
89
89
self .jsonp_data_flag = False
90
+ self .jsonp_data_url_list = [] # DEM 2017/07/27: List of JSON data sources
90
91
91
92
# set drilldown data
92
93
self .drilldown_data = []
93
94
self .drilldown_data_temp = []
94
-
95
+
95
96
# javascript
96
97
self .jscript_head_flag = False
97
98
self .jscript_head = kwargs .get ('jscript_head' , None )
@@ -220,10 +221,10 @@ def add_drilldown_data_set(self, data, series_type, id, **kwargs):
220
221
self .drilldown_data_set_count += 1
221
222
if self .drilldown_flag == False :
222
223
self .drilldown_flag = True
223
-
224
+
224
225
kwargs .update ({'id' :id })
225
226
series_data = Series (data , series_type = series_type , ** kwargs )
226
-
227
+
227
228
series_data .__options__ ().update (SeriesOptions (series_type = series_type , ** kwargs ).__options__ ())
228
229
self .drilldown_data_temp .append (series_data )
229
230
@@ -233,12 +234,17 @@ def add_data_from_jsonp(self, data_src, data_name='json_data', series_type="line
233
234
the data_src is the https link for data
234
235
and it must be in jsonp format
235
236
"""
236
- self .jsonp_data_flag = True
237
- self .jsonp_data_url = json .dumps (data_src )
238
- if data_name == 'data' :
239
- data_name = 'json_' + data_name
240
- self .jsonp_data = data_name
237
+ if not self .jsonp_data_flag :
238
+ self .jsonp_data_flag = True
239
+
240
+ if data_name == 'data' :
241
+ data_name = 'json_' + data_name
242
+
243
+ self .jsonp_data = data_name
241
244
self .add_data_set (RawJavaScriptText (data_name ), series_type , name = name , ** kwargs )
245
+ # DEM 2017/07/27: Append new JSON data source to a list instead of
246
+ # replacing whatever already exists
247
+ self .jsonp_data_url_list .append (json .dumps (data_src ))
242
248
243
249
244
250
def add_JSscript (self , js_script , js_loc ):
@@ -305,9 +311,14 @@ def buildcontent(self):
305
311
306
312
self .buildcontainer ()
307
313
self .option = json .dumps (self .options , cls = HighchartsEncoder )
308
- self .setoption = json .dumps (self .setOptions , cls = HighchartsEncoder )
314
+ self .setoption = json .dumps (self .setOptions , cls = HighchartsEncoder )
309
315
self .data = json .dumps (self .data_temp , cls = HighchartsEncoder )
310
-
316
+
317
+ # DEM 2017/04/25: Make 'data' available as an array
318
+ # ... this permits jinja2 array access to each data definition
319
+ # ... which is useful for looping over multiple data sources
320
+ self .data_list = [json .dumps (x , cls = HighchartsEncoder ) for x in self .data_temp ]
321
+
311
322
if self .drilldown_flag :
312
323
self .drilldown_data = json .dumps (self .drilldown_data_temp , cls = HighchartsEncoder )
313
324
self ._htmlcontent = self .template_content_highcharts .render (chart = self ).encode ('utf-8' )
0 commit comments