<commit_before>import './css/styles.scss';

if(module.hot) {
  module.hot.accept();
}

(function(H) {
  H.Chart.prototype.callbacks.push(function (chart) {

    if (chart.userOptions.dateRangeGrouping) {
      const chartRender = chart.renderTo;
      const btnList = [
        { text: 'Day',   dateObj: 'day' },
        { text: 'Week',  dateObj: 'week'  },
        { text: 'Month', dateObj: 'month' }
      ];

      var rawDataObj = {};

      /*
       * When making AJAX requests, adhere to addSeries interface
       * to trigger this event.
       */
      H.addEvent(chart, 'addSeries', function (e) {
        rawDataObj = rawData(chart, e.options.data, rawDataObj);
      });
      
      /*
       * If chart data is available upon load (non-AJAX)
       */
      H.addEvent(chart, 'load', function (e) {
        e.target.xAxis[0].series.forEach(i => {
          let yData = i.data.map(datum => datum.y);
          rawDataObj = rawData(chart, yData, rawDataObj);
        });
      });
      
      btnList.forEach(grouping => {
        let btn = document.createElement('button');
        btn.innerHTML += grouping.text;
        btn.classList.add('btn', 'btn-xs', '_hDateRangeGrouping');
        if (grouping.dateObj === 'day') btn.classList.add('active');
        btn.addEventListener('click', (e) => {
          viewBreakdown(chart, rawDataObj, grouping.dateObj);
          updateButtons(e.target);
        });
        chartRender.insertBefore(btn, chartRender.firstChild);
      });
    }
  });

  const rawData = (chart, data, container) => {
    let rawDataObj = container;
    let dateArr = chart.xAxis[0].categories.map(date => new Date(date).toISOString());

    data.forEach((dataPoint, i) => {
      rawDataObj[dateArr[i]] ? rawDataObj[dateArr[i]].push(dataPoint) : rawDataObj[dateArr[i]] = [dataPoint];
    });

    return rawDataObj;
  }<commit_msg>Utilize fat arrow syntax and let for raw data<commit_after>import './css/styles.scss';

if(module.hot) {
  module.hot.accept();
}

((H) => {
  H.Chart.prototype.callbacks.push((chart) => {

    if (chart.userOptions.dateRangeGrouping) {
      const chartRender = chart.renderTo;
      const btnList = [
        { text: 'Day',   dateObj: 'day' },
        { text: 'Week',  dateObj: 'week'  },
        { text: 'Month', dateObj: 'month' }
      ];

      let rawDataObj = {};

      /*
       * When making AJAX requests, adhere to addSeries interface
       * to trigger this event.
       */
      H.addEvent(chart, 'addSeries', (e) => {
        rawDataObj = rawData(chart, e.options.data, rawDataObj);
      });
      
      /*
       * If chart data is available upon load (non-AJAX)
       */
      H.addEvent(chart, 'load', (e) => {
        e.target.xAxis[0].series.forEach(i => {
          let yData = i.data.map(datum => datum.y);
          rawDataObj = rawData(chart, yData, rawDataObj);
        });
      });
      
      btnList.forEach(grouping => {
        let btn = document.createElement('button');
        btn.innerHTML += grouping.text;
        btn.classList.add('btn', 'btn-xs', '_hDateRangeGrouping');
        if (grouping.dateObj === 'day') btn.classList.add('active');
        btn.addEventListener('click', (e) => {
          viewBreakdown(chart, rawDataObj, grouping.dateObj);
          updateButtons(e.target);
        });
        chartRender.insertBefore(btn, chartRender.firstChild);
      });
    }
  });

  const rawData = (chart, data, container) => {
    let rawDataObj = container;
    let dateArr = chart.xAxis[0].categories.map(date => new Date(date).toISOString());

    data.forEach((dataPoint, i) => {
      rawDataObj[dateArr[i]] ? rawDataObj[dateArr[i]].push(dataPoint) : rawDataObj[dateArr[i]] = [dataPoint];
    });

    return rawDataObj;
  }
{'fraction_non_alphanumeric': 0.15959434214037896, 'fraction_numerical': 0.0010675206832132373, 'mean_word_length': 2.425959780621572, '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': '2039528', 'n_tokens_mistral': 1212, 'n_tokens_neox': 1194, 'n_words': 227}