@@ -737,7 +737,7 @@ def geo_json(self, geo_path=None, geo_str=None, data_out='data.json',
737
737
data = None , columns = None , key_on = None , threshold_scale = None ,
738
738
fill_color = 'blue' , fill_opacity = 0.6 , line_color = 'black' ,
739
739
line_weight = 1 , line_opacity = 1 , legend_name = None ,
740
- topojson = None , reset = False ):
740
+ topojson = None , reset = False , freescale = False ):
741
741
"""Apply a GeoJSON overlay to the map.
742
742
743
743
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',
804
804
keyword argument will enable conversion to GeoJSON.
805
805
reset: boolean, default False
806
806
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.
807
810
808
811
Output
809
812
------
@@ -892,8 +895,9 @@ def json_style(style_cnt, line_color, line_weight, line_opacity,
892
895
893
896
# D3 Color scale.
894
897
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
897
901
domain = threshold_scale or utilities .split_six (series = series )
898
902
if len (domain ) > 253 :
899
903
raise ValueError ('The threshold scale must be length <= 253' )
@@ -913,9 +917,21 @@ def json_style(style_cnt, line_color, line_weight, line_opacity,
913
917
# Create legend.
914
918
name = legend_name or columns [1 ]
915
919
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
+
919
935
self .template_vars .setdefault ('map_legends' , []).append (legend )
920
936
921
937
# Style with color brewer colors.
0 commit comments