js/crop_list.js
/* Updates the choropleth with data for the selected crop.*/
Updates the choropleth with data for the selected crop.
Updates the choropleth with data for the selected crop .
updateCropOnMap(that) {
        let choroplethResolution = 9;
        let cropElementMax =
            that.data.max_element_vals_for_each_crop[that.cropVis.selected_crop]["Production"]["y" + String(that.cropVis.active_year)];
        let choroplethDomain = [];
        for (let i = 0; i < choroplethResolution; i++) {
            choroplethDomain.push(i * (cropElementMax / choroplethResolution));
        }
        let colorScale = d3.scaleThreshold()
            .domain(choroplethDomain)
            .range(d3.schemeGreens[choroplethResolution]);
        d3.selectAll(".boundary")
            .style("fill", function (d) {
                let countryName = that.data.iso_countryName_map[d3.select(this).attr("id")];
                let country = that.data.countries[countryName];
                if (country != undefined) { 
                    let production = country[that.cropVis.selected_crop]["Production"]["y" + String(that.cropVis.active_year)];
                    return colorScale(production);
                }
            });
    }
updateCropOnMap ( that ) { let choroplethResolution = 9 ; let cropElementMax = that . data . max_element_vals_for_each_crop [ that . cropVis . selected_crop ] [ "Production" ] [ "y" + String ( that . cropVis . active_year ) ] ; let choroplethDomain = [ ] ; for ( let i = 0 ; i < choroplethResolution ; i ++ ) { choroplethDomain . push ( i * ( cropElementMax / choroplethResolution ) ) ; } let colorScale = d3 . scaleThreshold ( ) . domain ( choroplethDomain ) . range ( d3 . schemeGreens [ choroplethResolution ] ) ; d3 . selectAll ( ".boundary" ) . style ( "fill" , function ( d ) { let countryName = that . data . iso_countryName_map [ d3 . select ( this ) . attr ( "id" ) ] ; let country = that . data . countries [ countryName ] ; if ( country != undefined ) { let production = country [ that . cropVis . selected_crop ] [ "Production" ] [ "y" + String ( that . cropVis . active_year ) ] ; return colorScale ( production ) ; } } ) ; }
Updates the choropleth with data for the selected crop.
Updates the choropleth with data for the selected crop .
// There are some I just don't have data for, e.g. Greenland, Kosovo