@@ -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
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.
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 not freescale :
896
+ if freescale == False :
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,15 +918,18 @@ 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 })
921
+ 'lin_max' : int (domain [- 1 ]* 1.1 ),
922
+ 'tick_labels' : tick_labels ,
923
+ 'caption' : name })
924
+
925
+
924
926
else :
925
927
legend = leg_templ .render ({'lin_min' : domain [0 ],
926
928
'lin_max' : domain [- 1 ],
927
929
'tick_labels' : tick_labels ,
928
930
'caption' : name })
929
931
932
+
930
933
self .template_vars .setdefault ('map_legends' , []).append (legend )
931
934
932
935
# Style with color brewer colors.
@@ -1109,20 +1112,14 @@ def create_map(self, path='map.html', plugin_data_out=True, template=None):
1109
1112
def _repr_html_ (self ):
1110
1113
"""Build the HTML representation for IPython."""
1111
1114
self ._build_map () # Using the default templates.
1112
- html = self .HTML . encode ( 'utf8' )
1115
+ srcdoc = self .HTML
1113
1116
1114
1117
if self .json_data :
1115
1118
callback = 'function(callback){{callback(null, JSON.parse({}))}}'
1116
1119
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