<commit_before><!DOCTYPE html>
<meta charset="utf-8">
<style>
.q0-9 { fill:rgb(158,202,225); }
.q1-9 { fill:rgb(107,174,214); }
.q2-9 { fill:rgb(66,146,198); }
.q3-9 { fill:rgb(33,113,181); }
.q4-9 { fill:rgb(8,48,107); }
.q5-9 { fill:rgb(255,0,0); }
</style>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/queue.v1.min.js"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<script>
var width = 1024,
    height = 860;

var quantize = d3.scale.quantize()
    .domain([0, .15])
    .range(d3.range(6).map(function(i) {
      return "q" + i + "-9"; }));

var projection = d3.geo.albers()
    .center([31.4, 0])
    .rotate([0, -1, -1])
    .parallels([0, 0.1])
    .scale(1200 * 7)
    .translate([width / 2, height / 2]);

var path = d3.geo.path()
    .projection(projection);

var svg = d3.select("body").append("svg")
    .attr("width", width)
    .attr("height", height);

  queue()
    .defer(d3.json, "/static/map_resources/uganda-district.json")
    .defer(d3.json, "/survey/3/completion/json/")
    .await(ready)

function get_class_color(rate_value)
{
    return "q" + rate_value + "-9";
}

function get_rate_color(rate)
{
    final_rate = 0;

    if (typeof(rate) == "undefined"){
        return 5;
        }
    rate = parseInt(rate);

    if (rate >=0 && rate<20){
        final_rate = 0;
    }

    if (rate >=20 && rate <= 40)
    {
        final_rate = 1;
    }

    if (rate >40 && rate <= 60)
    {
        final_rate = 2;
    }

    if (rate >60 && rate <= 80)
    {
        final_rate = 3;
    }

    if (rate >80 && rate <= 100)
    {
        final_rate = 4;

    }

    return final_rate;
}

function ready(error, geoJson, completionRates) {
  console.log(arguments);
  svg.append("g")
      .attr("class", "districts")
    .selectAll("path")
      .data(topojson.feature(geoJson, geoJson.objects.districts).features)
    .enter().append("path")
      .attr("class", function(d) { 
        var rate = completionRates[(d.properties.name.toUpperCase())];
        return get_class_color(get_rate_color(rate));
      })
      .attr("d", path)
}
</script><commit_msg>[BRAIN/ANDREW] adding heat-ish map for completion rates<commit_after><!DOCTYPE html>
<meta charset="utf-8">
<style>
.q0-9 { fill:rgb(158,202,225); }
.q1-9 { fill:rgb(107,174,214); }
.q2-9 { fill:rgb(66,146,198); }
.q3-9 { fill:rgb(33,113,181); }
.q4-9 { fill:rgb(8,48,107); }
.q5-9 { fill:rgb(255,0,0); }
</style>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/queue.v1.min.js"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<script>
var width = 1024,
    height = 860;

var quantize = d3.scale.quantize()
    .domain([0, .15])
    .range(d3.range(6).map(function(i) {
      return "q" + i + "-9"; }));

var projection = d3.geo.albers()
    .center([31.4, 0])
    .rotate([0, -1, -1])
    .parallels([0, 0.1])
    .scale(1200 * 7)
    .translate([width / 2, height / 2]);

var path = d3.geo.path()
    .projection(projection);

var svg = d3.select("body").append("svg")
    .attr("width", width)
    .attr("height", height);

  queue()
    .defer(d3.json, "/static/map_resources/uganda-district.json")
    .defer(d3.json, "/survey/3/completion/json/")
    .await(ready)

function get_class_color(rate_value)
{
    return "q" + rate_value + "-9";
}

function get_rate_color(rate){
    if (typeof(rate) == "undefined") return 5;
    if (rate >= 0 && rate< 20) return 0
    if (rate >= 20 && rate <= 40) return 1
    if (rate > 40 && rate <= 60) return 2;
    if (rate > 60 && rate <= 80) return 3;
    if (rate > 80 && rate <= 100) return 4;
    return 0;
}

function ready(error, geoJson, completionRates) {
  console.log(arguments);
  svg.append("g")
      .attr("class", "districts")
    .selectAll("path")
      .data(topojson.feature(geoJson, geoJson.objects.districts).features)
    .enter().append("path")
      .attr("class", function(d) { 
        var rate = completionRates[(d.properties.name.toUpperCase())];
        return get_class_color(get_rate_color(rate));
      })
      .attr("d", path)
}
</script>
{'fraction_non_alphanumeric': 0.20892987139043923, 'fraction_numerical': 0.06309148264984227, 'mean_word_length': 2.9369627507163325, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4416117', 'n_tokens_mistral': 1782, 'n_tokens_neox': 1618, 'n_words': 300}