<commit_before>var graph;

function showTooltip(x, y, contents) {
    $('<div id="tooltip">' + contents + '</div>').css( {
        position: 'absolute',
        display: 'none',
        top: y + 5,
        left: x + 5,
        border: '1px solid #fdd',
        padding: '2px',
        'background-color': '#fee'
    }).appendTo("body").fadeIn(100);
};

function sortNumber(a, b)
{
    return a - b;
}

function load_data_callback(original_data){
    var parties = {};
    var minx = 1E100;
    var maxx = -1E100;
    var miny = 1E100;
    var maxy = -1E100;
    var values1 = [];
    var values2 = [];
    var var1_name = 'votes_count';
    var var2_name = 'discipline';
    for(var i=0;i<original_data.length;i++){
        party = original_data[i]['party'].replace(' ','_');
        var name = original_data[i]['name'];
        var var1 = original_data[i][var1_name];
        values1.push(var1);        
        if (var1>maxx)
            maxx = var1;
        if (var1<minx)
            minx = var1;
        var var2 = original_data[i][var2_name];
        values2.push(var2);
        if (var2>maxy)
            maxy = var2;
        if (var2<miny)
            miny = var2;
        var image_url = original_data[i]['img_url'];
        if (!(party in parties)) {
            parties[party] = {names:[],raw_data:[],data:[],image_url:[]};            
        }
        parties[party].names.push(name);
        parties[party].raw_data.push([var1,var2]);
        parties[party].image_url.push(image_url);
    };
    values1.sort(sortNumber);
    values2.sort(sortNumber);
    var scale1 = [values1[0]];
    var scale2 = [values2[0]];
    for (var i=1;i<values1.length/10;i++){
        if (values1[i*10]>scale1.slice(-1))
            scale1.push(values1[i*10]);
        if (values2[i*10]>scale2.slice(-1))
            scale2.push(values2[i*10]);
    }
    if (values1.slice(-1)>scale1.slice(-1))
        scale1.push(values1.slice(-1));
    if (values2.slice(-1)>scale2.slice(-1))
        scale2.push(values2.slice(-1));

    var k;
    var alpha;
    for (var i in parties){
        for (var j=0;j<parties[i].raw_data.length;j++){
            var var1 = parties[i].raw_data[j][0];
            var var2 = parties[i].raw_data[j][1];            
            for (k=0; k<scale1.length-1 & scale1[k]<=var1;k++){};
            alpha = (var1-scale1[k-1])/(scale1[k]-scale1[k-1]);
            var1 = k*(alpha)+(k-1)*(1-alpha);
            for (k=0; k<scale2.length-1 & scale2[k]<=var2;k++){};
            alpha = (var2-scale2[k-1])/(scale2[k]-scale2[k-1]);
            var2 = k*(alpha)+(k-1)*(1-alpha);
            parties[i].data.push([var1,var2]);
        };
    };<commit_msg>deal with invalid data (don't try to draw it)<commit_after>var graph;

function showTooltip(x, y, contents) {
    $('<div id="tooltip">' + contents + '</div>').css( {
        position: 'absolute',
        display: 'none',
        top: y + 5,
        left: x + 5,
        border: '1px solid #fdd',
        padding: '2px',
        'background-color': '#fee'
    }).appendTo("body").fadeIn(100);
};

function sortNumber(a, b)
{
    return a - b;
}

function load_data_callback(original_data){
    var parties = {};
    var minx = 1E100;
    var maxx = -1E100;
    var miny = 1E100;
    var maxy = -1E100;
    var values1 = [];
    var values2 = [];
    var var1_name = 'votes_count';
    var var2_name = 'discipline';
    for(var i=0;i<original_data.length;i++){
        party = original_data[i]['party'].replace(' ','_');
        var name = original_data[i]['name'];
        var var1 = original_data[i][var1_name];
        
        if (var1>maxx)
            maxx = var1;
        if (var1<minx)
            minx = var1;
        var var2 = original_data[i][var2_name];
        if ((var1!=null)&(var2!=null)){        
            values1.push(var1);        
            values2.push(var2);
            if (var2>maxy)
                maxy = var2;
            if (var2<miny)
                miny = var2;
            var image_url = original_data[i]['img_url'];
            if (!(party in parties)) {
                parties[party] = {names:[],raw_data:[],data:[],image_url:[]};            
            }
            parties[party].names.push(name);
            parties[party].raw_data.push([var1,var2]);
            parties[party].image_url.push(image_url);
        };
    };
    values1.sort(sortNumber);
    values2.sort(sortNumber);
    var scale1 = [values1[0]];
    var scale2 = [values2[0]];
    for (var i=1;i<values1.length/10;i++){
        if (values1[i*10]>scale1.slice(-1))
            scale1.push(values1[i*10]);
        if (values2[i*10]>scale2.slice(-1))
            scale2.push(values2[i*10]);
    }
    if (values1.slice(-1)>scale1.slice(-1))
        scale1.push(values1.slice(-1));
    if (values2.slice(-1)>scale2.slice(-1))
        scale2.push(values2.slice(-1));

    var k;
    var alpha;
    for (var i in parties){
        for (var j=0;j<parties[i].raw_data.length;j++){
            var var1 = parties[i].raw_data[j][0];
            var var2 = parties[i].raw_data[j][1];            
            for (k=0; k<scale1.length-1 & scale1[k]<=var1;k++){};
            alpha = (var1-scale1[k-1])/(scale1[k]-scale1[k-1]);
            var1 = k*(alpha)+(k-1)*(1-alpha);
            for (k=0; k<scale2.length-1 & scale2[k]<=var2;k++){};
            alpha = (var2-scale2[k-1])/(scale2[k]-scale2[k-1]);
            var2 = k*(alpha)+(k-1)*(1-alpha);
            parties[i].data.push([var1,var2]);
        };
    };
{'fraction_non_alphanumeric': 0.18485401459854015, 'fraction_numerical': 0.04598540145985401, 'mean_word_length': 2.084411930219471, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 19, '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': '3795107', 'n_tokens_mistral': 2036, 'n_tokens_neox': 1977, 'n_words': 334}