Map region colors

Different scales are supported in Mapviewer. linear or quantile or threshold scales can be defined based on the data. Mapviewer is agnostic to the scale -- that is, data needs to be precalculated as (in case of quantile scale) quantiles and colors need to be defined for each quantile range.

linear scale definition would be as follows.
// map_value - district specific values
domain_values.push(d3.min(map_value))
domain_values.push(d3.mean(map_value))
domain_values.push(d3.max(map_value))
// sets the domain_values from minimum to maximum values with a mid value
quantile scale definition would be as follows.
// consider below quantile calculation where 38 districts are uniformly categorized
var unique_districts = ['Araria', 'Arwal', ....] // 38 districts in Bihar
var category_length = Math.floor((unique_districts.length - 1) * 0.25)
var domain_values = []
for (var i = 0; i < 5; i++) {
  // map_value - district specific values
  domain_values.push(map_value[i * category_length])
}
threshold scale definition would be as follows.
domain_values = [0.34, 0.66, 1] // custom values can be defined here
{% apply only_source %}
{% end %}