<commit_before>(function(){
    var lastClicked;
    var boundaries;
    var map = L.map('map').fitBounds([[36.970298, -87.495199],[42.5083380000001,-91.5130789999999]]);
    L.tileLayer('https://{s}.tiles.mapbox.com/v3/datamade.hn83a654/{z}/{x}/{y}.png', {
        attribution: '<a href="http://www.mapbox.com/about/maps/" target="_blank">Terms &amp; Feedback</a>'
    }).addTo(map);
    var info = L.control({position: 'bottomleft'});
    info.onAdd = function(map){
        this._div = L.DomUtil.create('div', 'info');
        return this._div;
    }
    info.update = function(feature){
        if (typeof feature !== 'undefined'){
            $(this._div).html(featureInfo(feature.properties));
        } else {
            $(this._div).empty();
            info.removeFrom(map);
        }
    }

    var map_colors = [
        '#c7e9c0',
        '#a1d99b',
        '#74c476',
        '#31a354',
        '#006d2c'
    ]

    var jenks_cutoffs = []
    $.when($.getJSON('data/finished_files/merged_eitc.geojson')).then(
        function(shapes){
            boundaries = L.geoJson(shapes, {
                style: style,
                onEachFeature: boundaryClick
            }).addTo(map);

            var all_values = []
            boundaries.eachLayer(function(s){
                all_values.push(s.feature.properties['PCTEITC'] * 100);
            });
            jenks_cutoffs = jenks(all_values, 4);
            jenks_cutoffs[0] = 0; // ensure the bottom value is 0
            jenks_cutoffs.pop(); // last item is the max value, so dont use it
            console.log(jenks_cutoffs);

            //set the color style here!!
        }
    );
    function style(feature){
        var style = {
            "color": getColor(feature.properties['PCTEITC'] * 100),
            "opacity": 0.5,
            "weight": 1,
            "fillOpacity": 0.3,
        }
        return style;
    }

    // get color depending on condition_title
    function getColor(d) {
        console.log(d)
        return  d >= jenks_cutoffs[3] ? map_colors[0] : 
                d >= jenks_cutoffs[2] ? map_colors[1] : 
                d >= jenks_cutoffs[1] ? map_colors[2] : 
                d >= jenks_cutoffs[0] ? map_colors[3] :  
                                        map_colors[4];
    }

    function boundaryClick(feature, layer){
        layer.on('click', function(e){
            if(typeof lastClicked !== 'undefined'){
                boundaries.resetStyle(lastClicked);
            }
            e.target.setStyle({'fillColor':"#762a83"});
            info.update(feature);
            map.fitBounds(e.target.getBounds());<commit_msg>coloring map with jenks<commit_after>(function(){
    var lastClicked;
    var boundaries;
    var map = L.map('map').fitBounds([[36.970298, -87.495199],[42.5083380000001,-91.5130789999999]]);
    L.tileLayer('https://{s}.tiles.mapbox.com/v3/datamade.hn83a654/{z}/{x}/{y}.png', {
        attribution: '<a href="http://www.mapbox.com/about/maps/" target="_blank">Terms &amp; Feedback</a>'
    }).addTo(map);
    var info = L.control({position: 'bottomleft'});
    info.onAdd = function(map){
        this._div = L.DomUtil.create('div', 'info');
        return this._div;
    }
    info.update = function(feature){
        if (typeof feature !== 'undefined'){
            $(this._div).html(featureInfo(feature.properties));
        } else {
            $(this._div).empty();
            info.removeFrom(map);
        }
    }

    var map_colors = [
        '#006d2c',
        '#31a354',
        '#74c476',
        '#a1d99b',
        '#c7e9c0'
    ]

    var jenks_cutoffs = []
    $.when($.getJSON('data/finished_files/merged_eitc.geojson')).then(
        function(shapes){
            var all_values = []
            $.each(shapes.features, function(k, v){
                all_values.push(v.properties['PCTEITC'] * 100);
            });
            jenks_cutoffs = jenks(all_values, 4);
            jenks_cutoffs[0] = 0; // ensure the bottom value is 0
            jenks_cutoffs.pop(); // last item is the max value, so dont use it
            console.log(jenks_cutoffs)

            boundaries = L.geoJson(shapes, {
                style: style,
                onEachFeature: boundaryClick
            }).addTo(map);
        }
    );

    var legend = L.control({position: 'bottomright'});

    legend.onAdd = function (map) {

        var div = L.DomUtil.create('div', 'info legend'),
            grades = jenks_cutoffs,
            labels = [],
            from, to;

        for (var i = 0; i < grades.length; i++) {
            from = grades[i];
            to = grades[i + 1];

            labels.push(
                '<i style="background:' + getColor(from + 0.01) + '"></i> ' +
                from + (to ? '&ndash;' + to + "%" : "%" + '+'));
        }

        div.innerHTML = "<strong>EITC percent</strong><br>" + labels.join('<br>');
        return div;
    };

    legend.addTo(map);

    function style(feature){
        var style = {
            "color": "white",
            "fillColor": getColor(feature.properties['PCTEITC'] * 100),
            "opacity": 0.5,
            "weight": 1,
            "fillOpacity": 0.7,
        }
        return style;
    }

    // get color depending on condition_title
    function getColor(d) {
        return  d >= jenks_cutoffs[3] ? map_colors[0] : 
                d >= jenks_cutoffs[2] ? map_colors[1] : 
                d >= jenks_cutoffs[1] ? map_colors[2] : 
                d >= jenks_cutoffs[0] ? map_colors[3] :  
                                        map_colors[4];
    }

    function boundaryClick(feature, layer){
        layer.on('click', function(e){
            if(typeof lastClicked !== 'undefined'){
                boundaries.resetStyle(lastClicked);
            }
            e.target.setStyle({'fillColor':"#762a83"});
            info.update(feature);
            map.fitBounds(e.target.getBounds());
{'fraction_non_alphanumeric': 0.15565320263647117, 'fraction_numerical': 0.0349839445665033, 'mean_word_length': 1.8114014251781472, 'pattern_counts': {'":': 9, '<': 14, '<?xml version=': 0, '>': 21, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5464670', 'n_tokens_mistral': 2021, 'n_tokens_neox': 1859, 'n_words': 322}