var data = {};
var average = [0.2708, 0.3376, 0.2896];
var ctx = $("#ctx");
var tmp = new Chart(ctx, {type: "horizontalBar"});


function analyze() {
    var repoURL = $("#repoURL").val();
    $.ajax({
        url: "/analyze",
        data: {"URL": $("#repoURL").val()}, 
        success: function(result){
            data = result;
            populateCtx();
    }});
}

function populateCtx() {
    tmp.destroy();
    var ratios = [
        (data["test_lines"] / data["code_lines"]).toFixed(4),
        (data["test_classes"] / data["code_classes"]).toFixed(4),
        (data["test_functions"] / data["code_functions"]).toFixed(4)
        ];
    var bar = new Chart(ctx, {
        type: 'horizontalBar',
        data: {
            labels: ["Lines", "Classes", "Functions"],
            datasets: [
                {
                    label: data["project_name"],
                    backgroundColor: 'rgba(54, 162, 235, 0.4)',
                    data: ratios,
                    borderWidth: 1
                },
                {
                    label: "GitHub Average",
                    backgroundColor: 'rgba(255, 99, 132, 0.4)',
                    data: average,
                    borderWidth: 1
                }
            ]
        },
        options: {
            scales: {
                yAxes: [{
                    ticks: {
                        beginAtZero:true
                    }
                }]
            }
        }
    });
    tmp = bar;
}

@@ -120,16 +120,119 @@
 Bar%22%7D);%0A
+var ratios = %5B%5D;%0Avar weight = 1.5;%0A%0A%0Afunction sigmoid(x) %7B%0A    return 1 / (1 + Math.pow(Math.E, -x))%0A%7D%0A
 %0A%0Afuncti
@@ -517,20 +517,16 @@
 ();%0A    
-var 
 ratios =
@@ -1562,16 +1562,166 @@
     %7D);%0A
+    var score = sigmoid(weight * ((ratios%5B0%5D - average%5B0%5D) + (ratios%5B1%5D - average%5B1%5D) + (ratios%5B2%5D - average%5B2%5D)));%0A    alert((score*100).toFixed(2);%0A
     tmp 
@@ -1725,12 +1725,13 @@
 mp = bar;%0A%7D%0A
+%0A

Add score metric