<commit_before>
//Read Goals, Targets and Indicators
var sdgs = [];
var stats = {};

files = ["goals","targets","indicators"];
files.forEach(function (f) {
  console.log("Loading "+f);
  d3.json(f+".json", function (error, data) {
    //for (var attrname in data) { sdgs[attrname] = data[attrname]; }
    sdgs.push(data);
    if (sdgs.length==3) { data_loaded(sdgs); }
  });
});

function data_loaded(sdgs){
  console.log(sdgs);
  list_goals(sdgs);
  add_targets(sdgs);
  add_indicators(sdgs);
  update_stats(sdgs);
}

function update_stats(sdgs){
 document.getElementById("goals-num").innerHTML = sdgs[0]["goals"].length+" Goals";
 document.getElementById("targets-num").innerHTML = sdgs[1]["targets"].length+" Targets";
 document.getElementById("indicators-num").innerHTML = sdgs[2]["indicators"].length+" Indicators";
 add_stack_plot(stats);
}

function add_stack_plot(stats){
 var data = {
    labels: d3.range(1, sdgs[0]["goals"].length+1),
    datasets: [
        {
            label: "Targets",
            fillColor: "rgba(220,220,220,0.5)",
            strokeColor: "rgba(220,220,220,0.8)",
            highlightFill: "rgba(220,220,220,0.75)",
            highlightStroke: "rgba(220,220,220,1)",
            data: stats["goal_targets"] 
        },
        {
            label: "Indicators",
            fillColor: "rgba(151,187,205,0.5)",
            strokeColor: "rgba(151,187,205,0.8)",
            highlightFill: "rgba(151,187,205,0.75)",
            highlightStroke: "rgba(151,187,205,1)",
            data: stats["goal_indicators"] 
        }
    ]
 };
 var options = {
    scaleBeginAtZero : true,
    scaleShowGridLines : true,
    scaleGridLineColor : "rgba(0,0,0,.05)",
    scaleGridLineWidth : 1,
    scaleShowHorizontalLines: true,
    scaleShowVerticalLines: true,
    barShowStroke : true,
    barStrokeWidth : 2,
    barValueSpacing : 5,
    barDatasetSpacing : 1,

}

 var canvas = document.getElementById("barplot")
 var ctx= canvas.getContext("2d"); 
 var myBarChart = new Chart(ctx).Bar(data, options);
} 
  
  
  
  
  
function list_goals(sdgs){
  var sdgList = document.getElementById("sdgList"); 
  var goals=sdgs[0]["goals"];
  stats["goals"]=goals.length;
  for (var i in goals){
    var goal= goals[i];
    append_li(sdgList,"goal-"+goal["goal"],goal["goal"]+": "+goal["title"]);
  }
}

function append_li(hookElement,id,value){
  var newListItem = document.createElement("li");
  newListItem.setAttribute("id", id);
  var ListValue = document.createTextNode(value);<commit_msg>Units for tooltips and Goals<commit_after>
//Read Goals, Targets and Indicators
var sdgs = [];
var stats = {};

files = ["goals","targets","indicators"];
files.forEach(function (f) {
  console.log("Loading "+f);
  d3.json(f+".json", function (error, data) {
    //for (var attrname in data) { sdgs[attrname] = data[attrname]; }
    sdgs.push(data);
    if (sdgs.length==3) { data_loaded(sdgs); }
  });
});

function data_loaded(sdgs){
  console.log(sdgs);
  list_goals(sdgs);
  add_targets(sdgs);
  add_indicators(sdgs);
  update_stats(sdgs);
}

function update_stats(sdgs){
 document.getElementById("goals-num").innerHTML = sdgs[0]["goals"].length+" Goals";
 document.getElementById("targets-num").innerHTML = sdgs[1]["targets"].length+" Targets";
 document.getElementById("indicators-num").innerHTML = sdgs[2]["indicators"].length+" Indicators";
 add_stack_plot(stats);
}

function add_stack_plot(stats){
 var data = {
    labels: d3.range(1, sdgs[0]["goals"].length+1).map(function(i){return "Goal "+i}),
    datasets: [
        {
            label: "Targets",
            fillColor: "rgba(220,220,220,0.5)",
            strokeColor: "rgba(220,220,220,0.8)",
            highlightFill: "rgba(220,220,220,0.75)",
            highlightStroke: "rgba(220,220,220,1)",
            data: stats["goal_targets"] 
        },
        {
            label: "Indicators",
            fillColor: "rgba(151,187,205,0.5)",
            strokeColor: "rgba(151,187,205,0.8)",
            highlightFill: "rgba(151,187,205,0.75)",
            highlightStroke: "rgba(151,187,205,1)",
            data: stats["goal_indicators"] 
        }
    ]
 };
 var options = {
    scaleBeginAtZero : true,
    scaleShowGridLines : true,
    scaleGridLineColor : "rgba(0,0,0,.05)",
    scaleGridLineWidth : 1,
    scaleShowHorizontalLines: true,
    scaleShowVerticalLines: true,
    barShowStroke : true,
    barStrokeWidth : 2,
    barValueSpacing : 5,
    barDatasetSpacing : 1,

}

 var canvas = document.getElementById("barplot")
 var ctx= canvas.getContext("2d"); 
 Chart.defaults.global.multiTooltipTemplate = "<%= value %> <%= datasetLabel %> ";
 var myBarChart = new Chart(ctx).Bar(data, options);
 
} 
  
  
  
  
  
function list_goals(sdgs){
  var sdgList = document.getElementById("sdgList"); 
  var goals=sdgs[0]["goals"];
  stats["goals"]=goals.length;
  for (var i in goals){
    var goal= goals[i];
    append_li(sdgList,"goal-"+goal["goal"],goal["goal"]+": "+goal["title"]);
  }
}

function append_li(hookElement,id,value){
  var newListItem = document.createElement("li");
  newListItem.setAttribute("id", id);
  var ListValue = document.createTextNode(value);
{'fraction_non_alphanumeric': 0.17076952897848421, 'fraction_numerical': 0.04186857918201202, 'mean_word_length': 3.6195165622202325, 'pattern_counts': {'":': 2, '<': 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': '4688381', 'n_tokens_mistral': 1936, 'n_tokens_neox': 1791, 'n_words': 294}