@@ -737,7 +737,7 @@ def geo_json(self, geo_path=None, geo_str=None, data_out='data.json',
737737 data = None , columns = None , key_on = None , threshold_scale = None ,
738738 fill_color = 'blue' , fill_opacity = 0.6 , line_color = 'black' ,
739739 line_weight = 1 , line_opacity = 1 , legend_name = None ,
740- topojson = None , reset = False ):
740+ topojson = None , reset = False , freescale = False ):
741741 """Apply a GeoJSON overlay to the map.
742742
743743 Plot a GeoJSON overlay on the base map. There is no requirement
@@ -804,6 +804,9 @@ def geo_json(self, geo_path=None, geo_str=None, data_out='data.json',
804804 keyword argument will enable conversion to GeoJSON.
805805 reset: boolean, default False
806806 Remove all current geoJSON layers, start with new layer
807+ freescale: if True use free format for the scale, where min and max values
808+ are taken from the data. It also allow to plot allow to plot values < 0
809+ and float legend labels.
807810
808811 Output
809812 ------
@@ -892,8 +895,9 @@ def json_style(style_cnt, line_color, line_weight, line_opacity,
892895
893896 # D3 Color scale.
894897 series = data [columns [1 ]]
895- if threshold_scale and len (threshold_scale ) > 6 :
896- raise ValueError
898+ if freescale == False :
899+ if threshold_scale and len (threshold_scale ) > 6 :
900+ raise ValueError
897901 domain = threshold_scale or utilities .split_six (series = series )
898902 if len (domain ) > 253 :
899903 raise ValueError ('The threshold scale must be length <= 253' )
@@ -913,9 +917,21 @@ def json_style(style_cnt, line_color, line_weight, line_opacity,
913917 # Create legend.
914918 name = legend_name or columns [1 ]
915919 leg_templ = self .env .get_template ('d3_map_legend.js' )
916- legend = leg_templ .render ({'lin_max' : int (domain [- 1 ]* 1.1 ),
917- 'tick_labels' : tick_labels ,
918- 'caption' : name })
920+
921+ if not freescale :
922+ legend = leg_templ .render ({'lin_min' : 0 ,
923+ 'lin_max' : int (domain [- 1 ]* 1.1 ),
924+ 'tick_labels' : tick_labels ,
925+ 'caption' : name })
926+
927+
928+ else :
929+ legend = leg_templ .render ({'lin_min' : domain [0 ],
930+ 'lin_max' : domain [- 1 ],
931+ 'tick_labels' : tick_labels ,
932+ 'caption' : name })
933+
934+
919935 self .template_vars .setdefault ('map_legends' , []).append (legend )
920936
921937 # Style with color brewer colors.
0 commit comments