<commit_before>
var chartSize = { w: 800, h: 250 };
var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", 
              "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];

var maxYear = minYear = 2013;

var titles = {
  users: 'Users',
  projects: 'Projects',
  dashboards: 'Dashboards',
  collections: 'Collections',
};

var colors = ['95AD7E', '8DC6C4', 'C983A4', 'E24F8B', '3992CA', 'F0DB79'];

window.addEventListener('load', function(){
  
  Chart.defaults.global.responsive = true;
  Chart.defaults.global.tooltipFontFamily = "'Open Sans', sans-serif";
  Chart.defaults.global.tooltipTitleFontFamily = "'Open Sans', sans-serif";

  setMaxYear();

  window.ctn = document.getElementById('page');

  sumByYear();

  for (var chart in titles){
    createLineChart(chart);
  }

});

function setMaxYear(){
  for (var type in window.metrics){
    var data = window.metrics[type].data;

    data.forEach(function(item){
      maxYear = (item.date.year > maxYear ? item.date.year : maxYear);
    });
  }
}

function sumByYear(){
  for (var type in window.metrics){
    var data = window.metrics[type].data;
    var year, years = [], sum;

    data.forEach(function(item){

      if (item.date.year !== year){
        year = item.date.year;
        years.push({
          year: year,
          sum: 0
        });
      }

      years[years.length-1].sum += item.count;
    });

    window.metrics[type].years = years;
  }

  console.log(window.metrics);
}

function getCounts(type, year){
  var data = window.metrics[type].data;
  var result = [];
  
  for(var i=0;i<12;i++) 
    result.push(0);
  
  data.forEach(function(item){
    if (item.date.year === year){
      result[item.date.month] = item.count;
    }
  });

  return result;
}

function createLineChart(type, options){<commit_msg>fixed bug when no year defined for a metric<commit_after>
var chartSize = { w: 800, h: 250 };
var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", 
              "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];

var maxYear = minYear = 2013;

var titles = {
  users: 'Users',
  projects: 'Projects',
  dashboards: 'Dashboards',
  collections: 'Collections',
};

var colors = ['95AD7E', '8DC6C4', 'C983A4', 'E24F8B', '3992CA', 'F0DB79'];

window.addEventListener('load', function(){
  
  Chart.defaults.global.responsive = true;
  Chart.defaults.global.tooltipFontFamily = "'Open Sans', sans-serif";
  Chart.defaults.global.tooltipTitleFontFamily = "'Open Sans', sans-serif";

  setMaxYear();

  window.ctn = document.getElementById('page');

  sumByYear();

  for (var chart in titles){
    createLineChart(chart);
  }

});

function setMaxYear(){
  for (var type in window.metrics){
    var data = window.metrics[type].data;

    data.forEach(function(item){
      maxYear = (item.date.year > maxYear ? item.date.year : maxYear);
    });
  }
}

function sumByYear(){
  for (var type in window.metrics){
    var data = window.metrics[type].data;
    var year, years = [], sum;

    data.forEach(function(item){

      if (item.date.year !== year){
        year = item.date.year;
        years.push({
          year: year,
          sum: 0
        });
      }

      if (!years[years.length-1]){
        years.push({
          year: item.date.year,
          sum: 0
        }); 
      }
      
      years[years.length-1].sum += item.count;
    });

    window.metrics[type].years = years;
  }

  console.log(window.metrics);
}

function getCounts(type, year){
  var data = window.metrics[type].data;
  var result = [];
  
  for(var i=0;i<12;i++) 
    result.push(0);
  
  data.forEach(function(item){
    if (item.date.year === year){
      result[item.date.month] = item.count;
    }
  });

  return result;
}

function createLineChart(type, options){
{'fraction_non_alphanumeric': 0.17295850066934404, 'fraction_numerical': 0.019812583668005354, 'mean_word_length': 2.920251836306401, 'pattern_counts': {'":': 0, '<': 5, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5133022', 'n_tokens_mistral': 1347, 'n_tokens_neox': 1260, 'n_words': 280}