<commit_before>Gratipay.charts = {};


Gratipay.charts.make = function(series) {
    // Takes an array of data points.

    if (!series.length) {
        $('.chart-wrapper').remove();
        return;
    }


    // Reverse the series.
    // ===================
    // For historical reasons it comes to us in the opposite order from what we
    // want.

    series.reverse();


    // Gather charts.
    // ==============
    // Sniff the first element to determine what data points are available, and
    // then search the page for chart containers matching each data point
    // variable name.

    var point  = series[0];
    var charts = [];

    for (var varname in point) {
        var chart = $('#chart_'+varname);
        if (chart.length) {
            chart.varname = varname;
            charts.push(chart);
        }
    }

    var flagRoom = 20;
    var H = $('.chart').height() - flagRoom;
    var nitems = series.length;
    var w = (1 / nitems * 100).toFixed(10) + '%';


    // Compute maxes and scales.
    // =========================

    var maxes  = [];
    var scales = [];

    for (var i=0, point; point = series[i]; i++) {
        for (var j=0, chart; chart = charts[j]; j++) {
            maxes[j] = Math.max(maxes[j] || 0, point[chart.varname]);
        }
    }

    for (var i=0, len=maxes.length; i < len; i++) {
        scales.push(Math.ceil(maxes[i] / 100) * 100);
    }


    // Draw bars.
    // ==========

    function Bar(i, j, N, y, xText, xTitle) {
        var yParsed = parseFloat(y);
        var bar = $(document.createElement('div')).addClass('bar');
        var shaded = $(document.createElement('div')).addClass('shaded');
        shaded.html('<span class="y-label">'+ yParsed.toFixed() +'</span>');
        bar.append(shaded);

        var xTick = $(document.createElement('span')).addClass('x-tick');
        xTick.text(xText).attr('title', xTitle);
        bar.append(xTick);

        // Display a max flag (only once)
        if (yParsed === maxes[j]) {
            maxes[j] = undefined;
            bar.addClass('flagged');<commit_msg>Use jQuery idiom for creating new elements<commit_after>Gratipay.charts = {};


Gratipay.charts.make = function(series) {
    // Takes an array of data points.

    if (!series.length) {
        $('.chart-wrapper').remove();
        return;
    }


    // Reverse the series.
    // ===================
    // For historical reasons it comes to us in the opposite order from what we
    // want.

    series.reverse();


    // Gather charts.
    // ==============
    // Sniff the first element to determine what data points are available, and
    // then search the page for chart containers matching each data point
    // variable name.

    var point  = series[0];
    var charts = [];

    for (var varname in point) {
        var chart = $('#chart_'+varname);
        if (chart.length) {
            chart.varname = varname;
            charts.push(chart);
        }
    }

    var flagRoom = 20;
    var H = $('.chart').height() - flagRoom;
    var nitems = series.length;
    var w = (1 / nitems * 100).toFixed(10) + '%';


    // Compute maxes and scales.
    // =========================

    var maxes  = [];
    var scales = [];

    for (var i=0, point; point = series[i]; i++) {
        for (var j=0, chart; chart = charts[j]; j++) {
            maxes[j] = Math.max(maxes[j] || 0, point[chart.varname]);
        }
    }

    for (var i=0, len=maxes.length; i < len; i++) {
        scales.push(Math.ceil(maxes[i] / 100) * 100);
    }


    // Draw bars.
    // ==========

    function Bar(i, j, N, y, xText, xTitle) {
        var yParsed = parseFloat(y);
        var bar = $('<div>').addClass('bar');
        var shaded = $('<div>').addClass('shaded');
        shaded.html('<span class="y-label">'+ yParsed.toFixed() +'</span>');
        bar.append(shaded);

        var xTick = $('<span>').addClass('x-tick');
        xTick.text(xText).attr('title', xTitle);
        bar.append(xTick);

        // Display a max flag (only once)
        if (yParsed === maxes[j]) {
            maxes[j] = undefined;
            bar.addClass('flagged');
{'fraction_non_alphanumeric': 0.19062575501328824, 'fraction_numerical': 0.009180961584923895, 'mean_word_length': 2.094170403587444, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 10, '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': '2603024', 'n_tokens_mistral': 1354, 'n_tokens_neox': 1270, 'n_words': 343}