<commit_before>(function() {

  function render(metros) {
    // Basic set up of dimensions and sizes
    var el = d3.select('.js-canvas'),
       margin = { top: 20, right: 20, bottom: 0, left: 20 },
       width  = parseFloat(el.style('width')) - margin.left - margin.right,
       height = 1200 //parseFloat(el.style('height')) - margin.top - margin.bottom

    // Initialize a grid layout that will allow us to easily implement a
    // small-multiples-style visualization
    var grid = d3.layout.grid()
      .bands()
      .cols(6)
      .size([width, height])
      .padding([0.1, 0.1])

    var poveryRateMin   = 0,
        poveryRateMax   = 100,
        populationMin   = d3.min(metros, function(d) { return d.values.populationExtent[0] }),
        populationMax   = d3.max(metros, function(d) { return d.values.populationExtent[1] }),
        povertyCountMin = d3.min(metros, function(d) { return d.values.povcountExtent[0] }),
        povertyCountMax = d3.max(metros, function(d) { return d.values.povcountExtent[1] })

    console.log(populationMin, populationMax, povertyCountMin, povertyCountMax);
    // Create the main SVG container element with the proper size
    var vis = el.append('svg')
      .attr('width', width + margin.left + margin.right)
      .attr('height', height + margin.bottom + margin.top)
    .append('g')
      .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')')

    // Create and position a plot for each metro area
    var plot = vis.selectAll('.plot')
      .data(grid(metros))
    .enter().append('g')
      .attr('transform', function(d) { return "translate(" + d.x + "," + d.y + ")" })
      .attr('class', 'plot')

    // Add the metro title to each plot
    plot.append('text')
      .attr('class', 'title')
      .text(function(d) {
        var parts = d.key.split(',')
        return parts[0].split('-')[0].split('/')[0] + ', ' + parts[1].split('-')[0]
      })
  }

  d3.json('/metros.json', render)
})()
<commit_msg>move metro name simplification to a function<commit_after>(function() {

  function render(metros) {
    // Basic set up of dimensions and sizes
    var el = d3.select('.js-canvas'),
       margin = { top: 20, right: 20, bottom: 0, left: 20 },
       width  = parseFloat(el.style('width')) - margin.left - margin.right,
       height = 1200 //parseFloat(el.style('height')) - margin.top - margin.bottom

    // Initialize a grid layout that will allow us to easily implement a
    // small-multiples-style visualization
    var grid = d3.layout.grid()
      .bands()
      .cols(6)
      .size([width, height])
      .padding([0.1, 0.1])

    var poveryRateMin   = 0,
        poveryRateMax   = 100,
        populationMin   = d3.min(metros, function(d) { return d.values.populationExtent[0] }),
        populationMax   = d3.max(metros, function(d) { return d.values.populationExtent[1] }),
        povertyCountMin = d3.min(metros, function(d) { return d.values.povcountExtent[0] }),
        povertyCountMax = d3.max(metros, function(d) { return d.values.povcountExtent[1] })

    console.log(populationMin, populationMax, povertyCountMin, povertyCountMax);
    // Create the main SVG container element with the proper size
    var vis = el.append('svg')
      .attr('width', width + margin.left + margin.right)
      .attr('height', height + margin.bottom + margin.top)
    .append('g')
      .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')')

    // Create and position a plot for each metro area
    var plot = vis.selectAll('.plot')
      .data(grid(metros))
    .enter().append('g')
      .attr('transform', function(d) { return "translate(" + d.x + "," + d.y + ")" })
      .attr('class', 'plot')

    // Add the metro title to each plot
    plot.append('text')
      .attr('class', 'title')
      .text(formatMetroName)
  }

  // Private - Simplify metro name to the first metro and state
  function formatMetroName(tract) {
    var parts = tract.key.split(',')
    return parts[0].split('-')[0].split('/')[0] + ', ' + parts[1].split('-')[0]
  }

  d3.json('/metros.json', render)
})()

{'fraction_non_alphanumeric': 0.16707317073170733, 'fraction_numerical': 0.0175609756097561, 'mean_word_length': 2.7867036011080333, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2307618', 'n_tokens_mistral': 1365, 'n_tokens_neox': 1311, 'n_words': 318}