<commit_before>/* globals d3, $, _ */

$(window).ready(function () {
  var shas = window.location.hash.substr(1).split('..');
  var $gets = [];

  //var params = val.params;
  //var results = val.results;
  var testsDiv = d3.select("#tests");
  var data = {};
  var dataPerSha = [];

  // Generate XHR promises for each SHA
  $.each(shas, function (i, sha) {
    $gets.push($.getJSON(sha + '.json'));
  });

  // populate graphs with data when it's all loaded
  $.when.apply($.when, $gets).done(function () {
    if (shas.length === 1) {
      dataPerSha.push({
        sha: shas[0],
        color: 0,
        tests: arguments[0]
      });
    } else {
      for (var i = 0 ; i < arguments.length ; i += 1) {
        dataPerSha.push({
          sha: shas[i],
          color: i,
          tests: arguments[i][0]
        });
        $('#colors').append($('<div >').text(shas[i]).addClass(
          'color_' + i));
      }
    }
    for (var i = 0; i < dataPerSha.length ; i += 1) {
      var d = dataPerSha[i];
      $.each(d.tests, function (key, test) {
        if (!_.has(data, key)) {
          data[key] = {
            params: test.params,
            results: [],
          };
        }
        for (var j = 0; j < test.results.length ; j += 1) {
          var r = test.results[j];
          r.sha = d.sha;
          r.color = d.color,
          data[key].results.push(r);
        }
      });
    }

    data = _.map(data, function (val, key) {
      return {
        testName: key,
        params: val.params,
        results: val.results
      };
    });

    var svgWidth = 150;
    var svgHeight = 150;

    var chartEnter = testsDiv.data(data).enter()
                             .append('div')
                             .attr('class', 'chart');

    var legend = chartEnter.append('div').attr('class', 'legend')
                           .text(function (d) {
                             return d.params.api_method + ', ' +
                                 d.params.geom_complexity + ', ' +
                                 d.params.geom + ', ' +
                                 d.params.normalization + ', ' +
                                 d.params.boundary;
                           });
    var svgEnter = chartEnter.append("svg")
                             .attr("width", svgWidth)
                             .attr("height", svgHeight);


    var x = d3.local();
    var y = d3.local();
    var margin = {top: 20, right: 20, bottom: 30, left: 40},
        width = +svgWidth - margin.left - margin.right,
        height = +svgHeight - margin.top - margin.bottom;

    var svg = testsDiv.selectAll('svg')
                      .data(function (d) {
                        return d.results;
                      });
<commit_msg>fix width of svg<commit_after>/* globals d3, $, _ */

$(window).ready(function () {
  var shas = window.location.hash.substr(1).split('..');
  var $gets = [];

  //var params = val.params;
  //var results = val.results;
  var testsDiv = d3.select("#tests");
  var data = {};
  var dataPerSha = [];

  // Generate XHR promises for each SHA
  $.each(shas, function (i, sha) {
    $gets.push($.getJSON(sha + '.json'));
  });

  // populate graphs with data when it's all loaded
  $.when.apply($.when, $gets).done(function () {
    if (shas.length === 1) {
      dataPerSha.push({
        sha: shas[0],
        color: 0,
        tests: arguments[0]
      });
    } else {
      for (var i = 0 ; i < arguments.length ; i += 1) {
        dataPerSha.push({
          sha: shas[i],
          color: i,
          tests: arguments[i][0]
        });
        $('#colors').append($('<div >').text(shas[i]).addClass(
          'color_' + i));
      }
    }
    for (var i = 0; i < dataPerSha.length ; i += 1) {
      var d = dataPerSha[i];
      $.each(d.tests, function (key, test) {
        if (!_.has(data, key)) {
          data[key] = {
            params: test.params,
            results: [],
          };
        }
        for (var j = 0; j < test.results.length ; j += 1) {
          var r = test.results[j];
          r.sha = d.sha;
          r.color = d.color,
          data[key].results.push(r);
        }
      });
    }

    data = _.map(data, function (val, key) {
      return {
        testName: key,
        params: val.params,
        results: val.results
      };
    });

    var svgWidth = 250;
    var svgHeight = 150;

    var chartEnter = testsDiv.data(data).enter()
                             .append('div')
                             .attr('class', 'chart');

    var legend = chartEnter.append('div').attr('class', 'legend')
                           .text(function (d) {
                             return d.params.api_method + ', ' +
                                 d.params.geom_complexity + ', ' +
                                 d.params.geom + ', ' +
                                 d.params.normalization + ', ' +
                                 d.params.boundary;
                           });
    var svgEnter = chartEnter.append("svg")
                             .attr("width", svgWidth)
                             .attr("height", svgHeight);


    var x = d3.local();
    var y = d3.local();
    var margin = {top: 20, right: 20, bottom: 30, left: 40},
        width = +svgWidth - margin.left - margin.right,
        height = +svgHeight - margin.top - margin.bottom;

    var svg = testsDiv.selectAll('svg')
                      .data(function (d) {
                        return d.results;
                      });

{'fraction_non_alphanumeric': 0.15841943085009969, 'fraction_numerical': 0.010875475802066341, 'mean_word_length': 1.350085178875639, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7446262', 'n_tokens_mistral': 1745, 'n_tokens_neox': 1668, 'n_words': 375}