<commit_before>var d3 = require('d3');


exports.calculateScales = (chartWidth, chartHeight, xValues, yValues) => {

  var xScale, yScale;

  xScale = d3.scale.linear()
    .domain([d3.min([d3.min(xValues), 0]), d3.max(xValues)])
    .range([0, chartWidth]);

  yScale = d3.scale.linear()
    .domain([d3.min([d3.min(yValues), 0]), d3.max(yValues)])
    .range([chartHeight, 0]);

  return {
    xScale: xScale,
    yScale: yScale
  };

};


exports.flattenData = (data) => {

  var allValues = [];
  var xValues = [];
  var yValues = [];
  var coincidentCoordinateCheck = {};

  Object.keys(data).forEach( (seriesName) => {
    data[seriesName].forEach( (item, idx) => {
      // Check for NaN since d3's Voronoi cannot handle NaN values
      // Go ahead and Proceed to next iteration since we don't want NaN
      // in allValues or in xValues or yValues
      if (isNaN(item.x) || isNaN(item.y)) {
        return;
      }
      xValues.push(item.x);
      yValues.push(item.y);
      var xyCoords = item.x + "-" + item.y;
      if (xyCoords in coincidentCoordinateCheck) {
        // Proceed to next iteration if the x y pair already exists
        // d3's Voronoi cannot handle NaN values or coincident coords
        // But we push them into xValues and yValues above because
        // we still may handle them there (labels, etc.)
        return;
      }
      coincidentCoordinateCheck[xyCoords] = '';
      var pointItem = {
        coord: {
          x: item.x,
          y: item.y,
        },
        id: seriesName + '-' + idx
      };
      allValues.push(pointItem);
    });
  });
  return {
    allValues: allValues,
    xValues: xValues,
    yValues: yValues
  };
};



exports.shade = (hex, percent) => {

  var R, G, B, red, green, blue, number;
  var min = Math.min, round = Math.round;
  if(hex.length !== 7) { return hex; }
  number = parseInt(hex.slice(1), 16); 
  R = number >> 16;
  G = number >> 8 & 0xFF;
  B = number & 0xFF;
  red = min( 255, round( ( 1 + percent ) * R )).toString(16);
  green = min( 255, round( ( 1 + percent ) * G )).toString(16);
  blue = min( 255, round( ( 1 + percent ) * B )).toString(16);
  return '#' + red + green + blue; 

}; 

<commit_msg>Use es6 string template in utilsjs<commit_after>var d3 = require('d3');


exports.calculateScales = (chartWidth, chartHeight, xValues, yValues) => {

  var xScale, yScale;

  xScale = d3.scale.linear()
    .domain([d3.min([d3.min(xValues), 0]), d3.max(xValues)])
    .range([0, chartWidth]);

  yScale = d3.scale.linear()
    .domain([d3.min([d3.min(yValues), 0]), d3.max(yValues)])
    .range([chartHeight, 0]);

  return {
    xScale: xScale,
    yScale: yScale
  };

};


exports.flattenData = (data) => {

  var allValues = [];
  var xValues = [];
  var yValues = [];
  var coincidentCoordinateCheck = {};

  Object.keys(data).forEach( (seriesName) => {
    data[seriesName].forEach( (item, idx) => {
      // Check for NaN since d3's Voronoi cannot handle NaN values
      // Go ahead and Proceed to next iteration since we don't want NaN
      // in allValues or in xValues or yValues
      if (isNaN(item.x) || isNaN(item.y)) {
        return;
      }
      xValues.push(item.x);
      yValues.push(item.y);
      var xyCoords = `${ item.x }-${ item.y }`;
      if (xyCoords in coincidentCoordinateCheck) {
        // Proceed to next iteration if the x y pair already exists
        // d3's Voronoi cannot handle NaN values or coincident coords
        // But we push them into xValues and yValues above because
        // we still may handle them there (labels, etc.)
        return;
      }
      coincidentCoordinateCheck[xyCoords] = '';
      var pointItem = {
        coord: {
          x: item.x,
          y: item.y,
        },
        id: `${ seriesName }-${ idx }`
      };
      allValues.push(pointItem);
    });
  });
  return {
    allValues: allValues,
    xValues: xValues,
    yValues: yValues
  };
};



exports.shade = (hex, percent) => {

  var R, G, B, red, green, blue, number;
  var min = Math.min, round = Math.round;
  if(hex.length !== 7) { return hex; }
  number = parseInt(hex.slice(1), 16); 
  R = number >> 16;
  G = number >> 8 & 0xFF;
  B = number & 0xFF;
  red = min( 255, round( ( 1 + percent ) * R )).toString(16);
  green = min( 255, round( ( 1 + percent ) * G )).toString(16);
  blue = min( 255, round( ( 1 + percent ) * B )).toString(16);
  return `#${ red }${ green }${ blue }`; 

}; 


{'fraction_non_alphanumeric': 0.15540998418793767, 'fraction_numerical': 0.019652134628416536, 'mean_word_length': 2.437888198757764, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '6132475', 'n_tokens_mistral': 1606, 'n_tokens_neox': 1517, 'n_words': 423}