<commit_before>var blocks = [];

$(document).ready(function () {
    var main = new L.TileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
            attribution: 'Map data © OpenStreetMap contributors',
            minZoom: 5,
            maxZoom: 18,
        });
        counties = L.layerGroup(),
        current_towns = L.layerGroup();

    window.map = L.map('map-canvas', {
        center: [43.160552395407585, -77.60656356811523],
        zoom: 13,
        layers: [
            main
         ]
    });

   $.getJSON('/static/data/US/NY/055/US-NY-055-SHAPE.json', function (features) {
        csvToJson('/static/data/US/NY/055/US-NY-055-STATS.csv', function (stats) {
            L.geoJson(features, { 
                style: function (feature) {
                    var id = feature.properties['GEOID'];
                           return {
                               fillColor: "blue",
                               fillOpacity: 0
                            }
                },
                onEachFeature: function (feature, layer) {
                    layer.index = stats['Block Group ID'].indexOf(feature.properties.GEOID);
                    window.stats = stats;
                    if(layer.index !== -1) {
                        blocks.push(layer);
                    }                    
                }
            }).addTo(map);
            populateScale('Violent Crime Rate')

        });
    });
});

function populateScale (label) {
    stats[label] = stats[label].map(Number);
    var min = d3.min(stats[label]),
        max = d3.max(stats[label]),
        scale = d3.scale.linear();
    scale.domain([min, max])
        .range([0, 0.9]);

    blocks.forEach(function (block) {
        var val = parseFloat(stats[label][block.index]),
            o = scale(val);
        //console.log(o, val, min, max);
        block.setStyle({fillOpacity: o});
    });
    console.log(stats[label]);
}<commit_msg>Added a list of filters<commit_after>var blocks = [];

$(document).ready(function () {
    var main = new L.TileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
            attribution: 'Map data © OpenStreetMap contributors',
            minZoom: 5,
            maxZoom: 18,
        });
        counties = L.layerGroup(),
        current_towns = L.layerGroup();

    window.map = L.map('map-canvas', {
        center: [43.160552395407585, -77.60656356811523],
        zoom: 13,
        layers: [
            main
         ]
    });

   $.getJSON('/static/data/US/NY/055/US-NY-055-SHAPE.json', function (features) {
        csvToJson('/static/data/US/NY/055/US-NY-055-STATS.csv', function (stats) {
            L.geoJson(features, { 
                style: function (feature) {
                    var id = feature.properties['GEOID'];
                           return {
                               fillColor: "blue",
                               fillOpacity: 0
                            }
                },
                onEachFeature: function (feature, layer) {
                    layer.index = stats['Block Group ID'].indexOf(feature.properties.GEOID);
                    window.stats = stats;
                    if(layer.index !== -1) {
                        blocks.push(layer);
                    }                    
                }
            }).addTo(map);
            populateScale('Violent Crime Rate')

        });
    });
});

var filterOptions = [

    "% Bachelors or More",
    "% Commercial Land Use",
    "% High School or More",
    "% In Labor Force",
    "% Industrial Land Use",
    "% Other Land Use",
    "% Owner Occupied",
    "% Renter Occupied",
    "% Residential Land Use",
    "% School Aged Children",
    "% Vacant Land Use",
    "% on Public Assistance",
    "All Other Population",
    "American Indian Population",
    "Animal Calls Rate",
    "Asian Population",
    "Assessed Value 2012",
    "Black Population",
    "Blighted Properties",
    "Block Group ID",
    "Certs of Compliance/Occupancy Issued",
    "Child Poverty Rate",
    "City Demolitions",
    "Estimated Tax Bill 2012",
    "Forclosure Starts",
    "Household Size",
    "Households",
    "Land Value Per Acre 2012",
    "Median Household Income",
    "Nuisance Calls Rate",
    "Out of Town Owners",
    "Parcels",
    "PopDen",
    "Population",
    "Population 10-17",
    "Population 18-21",
    "Population 22-29",
    "Population 30's",
    "Population 40's",
    "Population 50's",
    "Population 60's";
    "Population Over 70",
    "Population Under 9",
    "Poverty Rate",
    "Property Crime Rate",
    "School Kids",
    "Square Miles",
    "Unemployment Rate",
    "Vacant Lots",
    "Vacant Structures",
    "Vice Calls Rate",
    "Violent Crime Rate",
    "White Population"
];

function populateScale (label) {
    stats[label] = stats[label].map(Number);
    var min = d3.min(stats[label]),
        max = d3.max(stats[label]),
        scale = d3.scale.linear();
    scale.domain([min, max])
        .range([0, 0.9]);

    blocks.forEach(function (block) {
        var val = parseFloat(stats[label][block.index]),
            o = scale(val);
        //console.log(o, val, min, max);
        block.setStyle({fillOpacity: o});
    });
    console.log(stats[label]);
}
{'fraction_non_alphanumeric': 0.1445920303605313, 'fraction_numerical': 0.028652751423149905, 'mean_word_length': 1.685175751400917, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '1958848', 'n_tokens_mistral': 1699, 'n_tokens_neox': 1534, 'n_words': 331}