<commit_before>/*! This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

/*jshint forin:true, noarg:true, noempty:true, eqeqeq:true, bitwise:true,
strict:true, undef:true, unused:true, curly:true, browser:true, white:true,
moz:true, esnext:false, indent:2, maxerr:50, devel:true, node:true, boss:true,
globalstrict:true, nomen:false, newcap:false */

'use strict';

function popularityComparator(rowA, rowB) {
  if (rowA.Total > rowB.Total) {
    return -1;
  }
  if (rowA.Total < rowB.Total) {
    return 1;
  }
  return 0;
}

function versionComparator(rowA, rowB) {
  var aVersion = /(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:\.(\d+))?/.exec(rowA.ProductVersion);
  if (aVersion) {
    aVersion = aVersion.slice(1).map((d) => new Number(d));
  }
  var bVersion = /(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:\.(\d+))?/.exec(rowB.ProductVersion);
  if (bVersion) {
    bVersion = bVersion.slice(1).map((d) => new Number(d));
  }

  if (aVersion === null && bVersion !== null) {
    return 1;
  } else if (aVersion !== null && bVersion === null) {
    return -1
  }

  if (aVersion[0] > bVersion[0]) {
    return -1;
  }
  if (aVersion[0] < bVersion[0]) {
    return 1;
  }
  if (aVersion[1] > bVersion[1]) {
    return -1;
  }
  if (aVersion[1] < bVersion[1]) {
    return 1;
  }
  if (aVersion[2] > bVersion[2]) {
    return -1;
  }
  if (aVersion[2] < bVersion[2]) {
    return 1;
  }
  return 0;
}


var chart;
var xOrder = 'VersionOrder';
var xScale;
var yScales = {};
var yScale;

function updateHeights () {
  var chart = d3.select('.chart');
  chart.selectAll('.bar').transition().attr({
    'y': function (d) {
      return yScale(d.Total);
    },
    'height': function (d) {
      return 90 - yScale(d.Total);
    }
  }).duration(500);
}

function updateXes () {
  var chart = d3.select('.chart');
  chart.selectAll('.bar').transition().attr({
    'x': function (d) {
      return xScale(d[xOrder]);
    }
  }).duration(500);
}
function draw(data) {
  var chart = d3.select('.chart');

  console.log("Length:", data.length);
  console.log("Map:", data.map((d) => d.ProductVersion));
  xScale = d3.scale.linear()
    .domain([0, data.length])
    .range([0, 150]);

  var yMax = d3.max(data.map((d) => d.Total));<commit_msg>Delay stuff by a bit.  It's cheap, but cute.  :)<commit_after>/*! This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

/*jshint forin:true, noarg:true, noempty:true, eqeqeq:true, bitwise:true,
strict:true, undef:true, unused:true, curly:true, browser:true, white:true,
moz:true, esnext:false, indent:2, maxerr:50, devel:true, node:true, boss:true,
globalstrict:true, nomen:false, newcap:false */

'use strict';

function popularityComparator(rowA, rowB) {
  if (rowA.Total > rowB.Total) {
    return -1;
  }
  if (rowA.Total < rowB.Total) {
    return 1;
  }
  return 0;
}

function versionComparator(rowA, rowB) {
  var aVersion = /(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:\.(\d+))?/.exec(rowA.ProductVersion);
  if (aVersion) {
    aVersion = aVersion.slice(1).map((d) => new Number(d));
  }
  var bVersion = /(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:\.(\d+))?/.exec(rowB.ProductVersion);
  if (bVersion) {
    bVersion = bVersion.slice(1).map((d) => new Number(d));
  }

  if (aVersion === null && bVersion !== null) {
    return 1;
  } else if (aVersion !== null && bVersion === null) {
    return -1
  }

  if (aVersion[0] > bVersion[0]) {
    return -1;
  }
  if (aVersion[0] < bVersion[0]) {
    return 1;
  }
  if (aVersion[1] > bVersion[1]) {
    return -1;
  }
  if (aVersion[1] < bVersion[1]) {
    return 1;
  }
  if (aVersion[2] > bVersion[2]) {
    return -1;
  }
  if (aVersion[2] < bVersion[2]) {
    return 1;
  }
  return 0;
}


var chart;
var xOrder = 'VersionOrder';
var xScale;
var yScales = {};
var yScale;

function updateHeights () {
  var chart = d3.select('.chart');
  chart.selectAll('.bar').transition().attr({
    'y': d => yScale(d.Total),
    'height': d => 90 - yScale(d.Total)
  }).duration(500)
  .delay((d,i) => 5 * i);
}

function updateXes () {
  var chart = d3.select('.chart');
  chart.selectAll('.bar').transition().attr({
    'x': d => xScale(d[xOrder])
  }).duration(500)
  .delay((d,i) => 5 * i);
}
function draw(data) {
  var chart = d3.select('.chart');

  console.log("Length:", data.length);
  console.log("Map:", data.map((d) => d.ProductVersion));
  xScale = d3.scale.linear()
    .domain([0, data.length])
    .range([0, 150]);

  var yMax = d3.max(data.map((d) => d.Total));
{'fraction_non_alphanumeric': 0.211184071171362, 'fraction_numerical': 0.022029231095106967, 'mean_word_length': 3.2888283378746594, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 24, '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': '5673979', 'n_tokens_mistral': 1882, 'n_tokens_neox': 1814, 'n_words': 414}