@@ -802,9 +802,9 @@ def geo_json(self, geo_path=None, geo_str=None, data_out='data.json',
802802 keyword argument will enable conversion to GeoJSON.
803803 reset: boolean, default False
804804 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.
808808
809809 Output
810810 ------
@@ -893,7 +893,7 @@ def json_style(style_cnt, line_color, line_weight, line_opacity,
893893
894894 # D3 Color scale.
895895 series = data [columns [1 ]]
896- if freescale == False :
896+ if not freescale :
897897 if threshold_scale and len (threshold_scale ) > 6 :
898898 raise ValueError
899899 domain = threshold_scale or utilities .split_six (series = series )
@@ -918,18 +918,15 @@ def json_style(style_cnt, line_color, line_weight, line_opacity,
918918
919919 if not freescale :
920920 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 })
926924 else :
927925 legend = leg_templ .render ({'lin_min' : domain [0 ],
928926 'lin_max' : domain [- 1 ],
929927 'tick_labels' : tick_labels ,
930928 'caption' : name })
931929
932-
933930 self .template_vars .setdefault ('map_legends' , []).append (legend )
934931
935932 # Style with color brewer colors.
@@ -1112,14 +1109,20 @@ def create_map(self, path='map.html', plugin_data_out=True, template=None):
11121109 def _repr_html_ (self ):
11131110 """Build the HTML representation for IPython."""
11141111 self ._build_map () # Using the default templates.
1115- srcdoc = self .HTML
1112+ html = self .HTML . encode ( 'utf8' )
11161113
11171114 if self .json_data :
11181115 callback = 'function(callback){{callback(null, JSON.parse({}))}}'
11191116 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