@@ -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
806- values are taken from the data. It also allow to plot
807- values < 0 and float legend labels.
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.
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 not freescale :
896+ if freescale == False :
897897 if threshold_scale and len (threshold_scale ) > 6 :
898898 raise ValueError
899899 domain = threshold_scale or utilities .split_six (series = series )
@@ -918,15 +918,18 @@ 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 })
921+ 'lin_max' : int (domain [- 1 ]* 1.1 ),
922+ 'tick_labels' : tick_labels ,
923+ 'caption' : name })
924+
925+
924926 else :
925927 legend = leg_templ .render ({'lin_min' : domain [0 ],
926928 'lin_max' : domain [- 1 ],
927929 'tick_labels' : tick_labels ,
928930 'caption' : name })
929931
932+
930933 self .template_vars .setdefault ('map_legends' , []).append (legend )
931934
932935 # Style with color brewer colors.
@@ -1109,20 +1112,14 @@ def create_map(self, path='map.html', plugin_data_out=True, template=None):
11091112 def _repr_html_ (self ):
11101113 """Build the HTML representation for IPython."""
11111114 self ._build_map () # Using the default templates.
1112- html = self .HTML . encode ( 'utf8' )
1115+ srcdoc = self .HTML
11131116
11141117 if self .json_data :
11151118 callback = 'function(callback){{callback(null, JSON.parse({}))}}'
11161119 for path , data in self .json_data .items ():
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 )
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 ))
0 commit comments