<commit_before> 

    /*global d3, startDate, endDate, startTime, endTime, formatWeek, formatHour, numberToHumanSize, formatFixed, formatDate, formatTime, numberWithDelimiter */

    // function barWidth(width,length){
    //   let calc_width = (width/(length)) - 2;
    //   let bar_width = calc_width;
    //   if (calc_width > 17){
    //     bar_width = 17;
    //   }else if(calc_width < 6){
    //     bar_width = 6;
    //   }
    //   return bar_width
    // }




    function setupUsage(data, yop, chartWidth){
      if(Number.isInteger("full") == false){
        var startDate = new Date(data[0].id);
        var today = new Date();
        var endDate = new Date(today.setMonth( today.getMonth())); // creates a bit of space at the end
      }
      else {
        var endDate = new Date(lastDataPoint.setMonth( lastDataPoint.getMonth() + 2 ));
        var startDate = new Date(lastDataPoint.setMonth( lastDataPoint.getMonth() - displayMode ));
      }

      if(yop){
        var startDate = new Date(yop+"-01-01");
      }

      let formatMonthYear = d3.time.format.utc("%b %Y");


      var domain = [startDate, endDate];
      var length = bins(yop,120) //d3.time.months(startDate, endDate).length;
      var firstLabel = formatMonthYear(startDate)
      var lastLabel = formatMonthYear(endDate)

      return {
        width: chartWidth,
        barWidth: chartWidth/length,
        firstLabel: firstLabel,
        lastLabel: lastLabel,
        length: length,
        domain: domain
      }
      
    }

    function setupCitations(data, yop, chartWidth ){

      var today = new Date();
      var endDate = new Date(today.setMonth( today.getMonth())); // c
      var fistDataPoint = new Date(data[0].id+"-01-01");
      var yopDate = new Date(yop+"-01-01");
      var startDate = (fistDataPoint > yopDate) ? yopDate : fistDataPoint
      console.log(fistDataPoint)
      console.log(yopDate)
      console.log(data[0].id)

      var startTime = startDate
      var endTime = today;
      var domain = [startTime, endTime];
      var length = bins(yop,10);
      var firstLabel = formatYear(startDate)
      var lastLabel = formatYear(endDate)

      return {
        width: chartWidth,
        barWidth: chartWidth/10,
        firstLabel: firstLabel,
        lastLabel: lastLabel,
        length: length,
        domain: domain
      }
    }

    function monthDiff(d1, d2) {
      var months;
      months = (d2.getFullYear() - d1.getFullYear()) * 12;
      months -= d1.getMonth() + 1;
      months += d2.getMonth();
      return months <= 0 ? 0 : months;
    }
  

    function bins(yop, maxBin) {
      var today = new Date();
      var yopDate = new Date(yop+"-01-01");
      
      if(monthDiff(yopDate, today) > 0){
        if(monthDiff(yopDate, today) < maxBin){
          return monthDiff(yopDate, today)
        }
      }else{
        return maxBin*.90;
      }
      return maxBin;
    }

    function bar2Viz(data, div, count, format, displayMode, yop) {

      var lastDataPoint = new Date(data[data.length - 1].id);
      var today = new Date();
      let setup;



      var timeStamp = null;
      let formatYear = d3.time.format.utc("%Y");
      let formatHour = d3.time.format.utc("%h");
      let formatMonthYear = d3.time.format.utc("%b %Y");
      let formatFixed = d3.format(",.0f");
      let formatTime = d3.time.format.utc("%H:%M:%S");
      let height = 200
      var margin = { top: 10, right: 20, bottom: 20, left: 20 };
 
      let chartWidth = document.getElementById("myTabContent").offsetWidth*0.95
      if(displayMode == "citations"){
        setup = setupCitations(data, yop, chartWidth )
      }
      else{
        setup = setupUsage(data, yop, chartWidth)
      }


      
      var x = d3.time.scale.utc()
        .domain(setup.domain)
        .nice(d3.time.month)
        .rangeRound([0, setup.width],0.5);<commit_msg>avoid very old yop rendering<commit_after> 

    /*global d3, startDate, endDate, startTime, endTime, formatWeek, formatHour, numberToHumanSize, formatFixed, formatDate, formatTime, numberWithDelimiter */

    // function barWidth(width,length){
    //   let calc_width = (width/(length)) - 2;
    //   let bar_width = calc_width;
    //   if (calc_width > 17){
    //     bar_width = 17;
    //   }else if(calc_width < 6){
    //     bar_width = 6;
    //   }
    //   return bar_width
    // }




    function setupUsage(data, yop, chartWidth){
      if(Number.isInteger("full") == false){
        var startDate = new Date(data[0].id);
        var today = new Date();
        var endDate = new Date(today.setMonth( today.getMonth())); // creates a bit of space at the end
      }
      else {
        var endDate = new Date(lastDataPoint.setMonth( lastDataPoint.getMonth() + 2 ));
        var startDate = new Date(lastDataPoint.setMonth( lastDataPoint.getMonth() - displayMode ));
      }

      if(yop){
        var startDate = new Date(yop+"-01-01");
      }

      let formatMonthYear = d3.time.format.utc("%b %Y");


      var domain = [startDate, endDate];
      var length = bins(yop,120) //d3.time.months(startDate, endDate).length;
      var firstLabel = formatMonthYear(startDate)
      var lastLabel = formatMonthYear(endDate)

      return {
        width: chartWidth,
        barWidth: chartWidth/length,
        firstLabel: firstLabel,
        lastLabel: lastLabel,
        length: length,
        domain: domain
      }
      
    }

    function setupCitations(data, yop, chartWidth ){

      var today = new Date();
      var endDate = new Date(today.setMonth( today.getMonth())); // c
      var fistDataPoint = new Date(data[0].id+"-01-01");
      var yopDate = new Date(yop+"-01-01");
      var startDate = (fistDataPoint > yopDate) ? yopDate : fistDataPoint
      var startDate = (today.getFullYear() - startDate.getFullYear()) < 10 ? startDate : new Date(startDate.setYear( today.getFullYear() - 10 ));
  
      var startTime = startDate
      var endTime = today;
      var domain = [startTime, endTime];
      var length = bins(yop,10);
      var firstLabel = formatYear(startDate)
      var lastLabel = formatYear(endDate)

      return {
        width: chartWidth,
        barWidth: chartWidth/10,
        firstLabel: firstLabel,
        lastLabel: lastLabel,
        length: length,
        domain: domain
      }
    }

    function monthDiff(d1, d2) {
      var months;
      months = (d2.getFullYear() - d1.getFullYear()) * 12;
      months -= d1.getMonth() + 1;
      months += d2.getMonth();
      return months <= 0 ? 0 : months;
    }
  

    function bins(yop, maxBin) {
      var today = new Date();
      var yopDate = new Date(yop+"-01-01");
      
      if(monthDiff(yopDate, today) > 0){
        if(monthDiff(yopDate, today) < maxBin){
          return monthDiff(yopDate, today)
        }
      }else{
        return maxBin*.90;
      }
      return maxBin;
    }

    function bar2Viz(data, div, count, format, displayMode, yop) {

      var lastDataPoint = new Date(data[data.length - 1].id);
      var today = new Date();
      let setup;

      var timeStamp = null;
      let formatYear = d3.time.format.utc("%Y");
      let formatHour = d3.time.format.utc("%h");
      let formatMonthYear = d3.time.format.utc("%b %Y");
      let formatFixed = d3.format(",.0f");
      let formatTime = d3.time.format.utc("%H:%M:%S");
      let height = 200
      var margin = { top: 10, right: 20, bottom: 20, left: 20 };
 
      let chartWidth = document.getElementById("myTabContent").offsetWidth*0.95
      if(displayMode == "citations"){
        setup = setupCitations(data, yop, chartWidth )
      }
      else{
        setup = setupUsage(data, yop, chartWidth)
      }


      
      var x = d3.time.scale.utc()
        .domain(setup.domain)
        .nice(d3.time.month)
        .rangeRound([0, setup.width],0.5);
{'fraction_non_alphanumeric': 0.1316898709924639, 'fraction_numerical': 0.020309107165666113, 'mean_word_length': 2.2395531650806784, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 9, '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': '2255692', 'n_tokens_mistral': 2646, 'n_tokens_neox': 2494, 'n_words': 590}