@@ -802,9 +802,9 @@ def geo_json(self, geo_path=None, geo_str=None, data_out='data.json',
802
802
keyword argument will enable conversion to GeoJSON.
803
803
reset: boolean, default False
804
804
Remove all current geoJSON layers, start with new layer
805
- freescale: if True use free format for the scale, where min and max values
806
- are taken from the data. It also allow to plot allow to plot values < 0
807
- and float legend labels.
805
+ freescale: if True use free format for the scale, where min and max
806
+ values are taken from the data. It also allow to plot
807
+ values < 0 and float legend labels.
808
808
809
809
Output
810
810
------
@@ -893,7 +893,7 @@ def json_style(style_cnt, line_color, line_weight, line_opacity,
893
893
894
894
# D3 Color scale.
895
895
series = data [columns [1 ]]
896
- if freescale == False :
896
+ if not freescale :
897
897
if threshold_scale and len (threshold_scale ) > 6 :
898
898
raise ValueError
899
899
domain = threshold_scale or utilities .split_six (series = series )
@@ -918,18 +918,15 @@ def json_style(style_cnt, line_color, line_weight, line_opacity,
918
918
919
919
if not freescale :
920
920
legend = leg_templ .render ({'lin_min' : 0 ,
921
- 'lin_max' : int (domain [- 1 ]* 1.1 ),
922
- 'tick_labels' : tick_labels ,
923
- 'caption' : name })
924
-
925
-
921
+ 'lin_max' : int (domain [- 1 ]* 1.1 ),
922
+ 'tick_labels' : tick_labels ,
923
+ 'caption' : name })
926
924
else :
927
925
legend = leg_templ .render ({'lin_min' : domain [0 ],
928
926
'lin_max' : domain [- 1 ],
929
927
'tick_labels' : tick_labels ,
930
928
'caption' : name })
931
929
932
-
933
930
self .template_vars .setdefault ('map_legends' , []).append (legend )
934
931
935
932
# Style with color brewer colors.
@@ -1112,14 +1109,20 @@ def create_map(self, path='map.html', plugin_data_out=True, template=None):
1112
1109
def _repr_html_ (self ):
1113
1110
"""Build the HTML representation for IPython."""
1114
1111
self ._build_map () # Using the default templates.
1115
- srcdoc = self .HTML
1112
+ html = self .HTML . encode ( 'utf8' )
1116
1113
1117
1114
if self .json_data :
1118
1115
callback = 'function(callback){{callback(null, JSON.parse({}))}}'
1119
1116
for path , data in self .json_data .items ():
1120
- json_data = json .dumps (data ).replace ('"' , '"' )
1121
- srcdoc = srcdoc .replace ('d3.json, {}' .format (repr (path )),
1122
- callback .format ((repr (json_data ))))
1123
- srcdoc = srcdoc .replace ('"' , '"' )
1124
- return ('<iframe srcdoc="{srcdoc}" style="width: 100%; height: 500px; '
1125
- 'border: none"></iframe>' .format (srcdoc = srcdoc ))
1117
+ json_data = json .dumps (data )
1118
+ html = html .replace ('d3.json, {}' .format (repr (path )),
1119
+ callback .format ((repr (json_data ))))
1120
+ html = html .replace ('"' , '"' )
1121
+ iframe = ('<iframe srcdoc="{}" width=100%; height=500px; '
1122
+ 'border: none"></iframe>' ).format
1123
+ else :
1124
+ encoded = base64 .b64encode (html )
1125
+ html = "data:text/html;base64," + encoded .decode ('utf8' )
1126
+ iframe = ('<iframe src="{}" width=100%; height=500px; '
1127
+ 'border: none"></iframe>' ).format
1128
+ return iframe (html )
0 commit comments