@@ -469,9 +469,11 @@ def choropleth(self, geo_data, data=None, columns=None, key_on=None,
469
469
start with 'feature' and be in JavaScript objection notation.
470
470
Ex: 'feature.id' or 'feature.properties.statename'.
471
471
threshold_scale: list, default None
472
- Data range for D3 threshold scale. Defaults to a linear scale of
473
- 6 bins going from min(values) to max(values).
474
- Values are expected to be sorted.
472
+ Defaults to a linear scale of 6 bins going from min(values)
473
+ to max(values). Values that are outside of the threshold_scale
474
+ domain will be mapped to the closest color bin
475
+ (i.e. the first or last bin of the scale)
476
+ The list is expected to be sorted.
475
477
fill_color: string, default 'blue'
476
478
Area fill color. Can pass a hex code, color name, or if you are
477
479
binding data, one of the following color brewer palettes:
@@ -570,22 +572,21 @@ def get_by_key(obj, key):
570
572
571
573
def color_scale_fun (x ):
572
574
key_of_x = get_by_key (x , key_on )
573
- if key_of_x in color_data .keys ():
574
- value_of_x = color_data [key_of_x ]
575
- else :
576
- # The value is missing
577
- value_of_x = None
578
-
579
- if value_of_x is None or np .isnan (value_of_x ):
580
- # The value is missing or is deliberately nan
575
+
576
+ if key_of_x not in color_data .keys ():
577
+ return nan_fill_color
578
+
579
+ value_of_x = color_data [key_of_x ]
580
+ if np .isnan (value_of_x ):
581
581
return nan_fill_color
582
- else :
583
- color_idx = int (np .digitize (value_of_x , color_domain )) - 1
584
- # we consider that values outside the color domain
585
- # should be affected to the first (or last) color bin.
586
- color_idx = max (0 , color_idx )
587
- color_idx = min (nb_bins - 1 , color_idx )
588
- return color_range [color_idx ]
582
+
583
+ color_idx = int (np .digitize (value_of_x , color_domain )) - 1
584
+ # we consider that values outside of the color domain
585
+ # should be mapped to the first (or last) color bin.
586
+ color_idx = max (0 , color_idx )
587
+ color_idx = min (nb_bins - 1 , color_idx )
588
+ return color_range [color_idx ]
589
+
589
590
else :
590
591
def color_scale_fun (x ):
591
592
return fill_color
@@ -629,8 +630,6 @@ def highlight_function(x):
629
630
color_scale = StepColormap (
630
631
brewed ,
631
632
index = color_domain ,
632
- vmin = color_domain [0 ],
633
- vmax = color_domain [- 1 ],
634
633
caption = legend_name ,
635
634
)
636
635
self .add_child (color_scale )
0 commit comments