<commit_before>(function ( $ ) {
    $.extend({
        draw: function() {
            var margin = 20;
            var barheight = 5, barpadding = 5, legend = 10;

            $("[data-graphit='overview']").each( function(i) {
                var q_i = i+1;
                var hits = [];
                hit_panels = $(this).find('.hitn')
                hit_panels.each (function(i) {
                    // _hsps = [$(this).data('hit-evalue')];
                    if( i >= 20 ) return false;
                    _hsps = []
                    $(this).find('.hsps').each (function(j) {
                        __hsps = []
                        __hsps = $(this).data();
                        //_hsps.push($(this).data());
                        __hsps['hspId'] = $(this).attr('id');
                        _hsps.push(__hsps);
                    });
                    _hsps['hitId'] = $(this).attr('id');
                    hits.push(_hsps);
                });
                
                if(hits.length < 1) return false;
                // Sort according to evalues
                // hits.sort(function(a,b) { return a.hitEvalue - b.hitEvalue; });

                // DEBUG
                // console.log(hits);

                query_len = $(this).data().queryLen;
                var graph_dom = $(this).children().eq(1).children().eq(0).after("<div class='graph'/>");
                width = $('.graph', this).width();
                height = hits.length*(barheight + barpadding) + 5*margin + legend*3;

                var svg = d3.select($(this).find('.graph')[0])
                            .data([hits])
                            .append('svg')
                            .attr('width', width)
                            .attr('height', height).append('g')
                            .attr('transform', 'translate('+margin/4+', '+margin/4+')');
                // DEBUG
                // console.log(svg);

                var x = d3.scale.linear().range([0, width-margin*2])
                x.domain([0, query_len]);
                var xAxis = d3.svg.axis()
                    .scale(x)
                    .orient('top')
                    .ticks(10);

                // Attach the axis to DOM (<svg> element)
                var scale = svg.append('g')
                            .attr('transform', 'translate(0, '+margin+')')
                            .append('g').attr('class', 'x axis')
                            .call(xAxis);

                var y = d3.scale.ordinal().rangeBands([0,height-3*margin-2*legend], .5);
                y.domain(hits.map( function(d, i) { return d.hitId; } ));

                /* Kept for future.
                var color = d3.scale.linear()
                            .domain((hits.map( function(d) { return d.hitId; } )).reverse())
                            .range(["red", "yellow", "green"]);
                */
                var color2 = d3.scale.ordinal()
                                .domain((hits.map( function(d) { return d.hitId; } )))
                                .rangeBands([10,150], 0.5);

                var t = svg.append('g').attr('transform', 'translate(0, '+(2*margin-legend)+')')
                    .selectAll('.hits')
                    .data(hits)
                    .enter()
                    .append('g')//.attr('transform', function(d,i) {
                        //return 'translate(0, '+y(d.hitId)+')';
                    //})
                    .each( function(d,i) {
                        var h_i = i+1;
                        /*
                        var color_hsp = d3.scale.ordinal()
                                        .domain((d.map( function(d) { return d.hspId; } )))
                                        .range(["blue", "red", "green", "yellow", "orange"]);
                        */
                        var p_hsp = d;
                        var p_id = d.hitId;
                        var p_count = d.length;

                        d3.select(this)
                            .selectAll('.hsps')
                            .data(d).enter()
                            .append('a')
                        .each( function(pd, j) {
                            //console.log(d3.select(this.parentNode).datum().hitId);
                            //
                            var y_hspline = y(p_id)+barheight/2;
                            var hspline_color = d3.rgb(20,20,20);

                            if (j+1 < p_count) {
                                if( p_hsp[j].hspEnd < p_hsp[j+1].hspStart ) {
                                    d3.select(this.parentNode).append('line')
                                        .attr('x1', x(p_hsp[j].hspEnd))
                                        .attr('y1', y_hspline)
                                        .attr('x2', x(p_hsp[j+1].hspStart))
                                        .attr('y2', y_hspline)
                                        .attr('stroke', hspline_color);
                                }
                                else if ( p_hsp[j].hspStart > p_hsp[j+1].hspEnd ) {
                                    d3.select(this.parentNode).append('line')
                                        .attr('x1', x(p_hsp[j+1].hspEnd))
                                        .attr('y1', y_hspline)
                                        .attr('x2', x(p_hsp[j].hspStart))
                                        .attr('y2', y_hspline)
                                        .attr('stroke', hspline_color);
                                };
                            };

                            d3.select(this)//.append('a')
                            .attr('xlink:href', function(d,i) {return '#Query_'+(q_i)+'_hit_'+(h_i);})
                            .append('rect')
                            .attr('x', function(d) {
                                if(d.hspFrame < 0)
                                    return x(d.hspStart);
                                else
                                    return x(d.hspStart);
                            })<commit_msg>Reduce margin on right of overview graphic, color change to hsp connector line<commit_after>(function ( $ ) {
    $.extend({
        draw: function() {
            var margin = 20;
            var barheight = 5, barpadding = 5, legend = 10;

            $("[data-graphit='overview']").each( function(i) {
                var q_i = i+1;
                var hits = [];
                hit_panels = $(this).find('.hitn')
                hit_panels.each (function(i) {
                    // _hsps = [$(this).data('hit-evalue')];
                    if( i >= 20 ) return false;
                    _hsps = []
                    $(this).find('.hsps').each (function(j) {
                        __hsps = []
                        __hsps = $(this).data();
                        //_hsps.push($(this).data());
                        __hsps['hspId'] = $(this).attr('id');
                        _hsps.push(__hsps);
                    });
                    _hsps['hitId'] = $(this).attr('id');
                    hits.push(_hsps);
                });

                if(hits.length < 1) return false;
                // Sort according to evalues
                // hits.sort(function(a,b) { return a.hitEvalue - b.hitEvalue; });

                // DEBUG
                // console.log(hits);

                query_len = $(this).data().queryLen;
                var graph_dom = $(this).children().eq(1).children().eq(0).after("<div class='graph'/>");
                width = $('.graph', this).width();
                height = hits.length*(barheight + barpadding) + 5*margin + legend*3;

                var svg = d3.select($(this).find('.graph')[0])
                            .data([hits])
                            .append('svg')
                            .attr('width', width)
                            .attr('height', height).append('g')
                            .attr('transform', 'translate('+margin/4+', '+margin/4+')');
                // DEBUG
                // console.log(svg);

                var x = d3.scale.linear().range([0, width-margin])
                x.domain([0, query_len]);
                var xAxis = d3.svg.axis()
                    .scale(x)
                    .orient('top')
                    .ticks(11);

                // Attach the axis to DOM (<svg> element)
                var scale = svg.append('g')
                            .attr('transform', 'translate(0, '+margin+')')
                            .append('g').attr('class', 'x axis')
                            .call(xAxis);

                var y = d3.scale.ordinal().rangeBands([0,height-3*margin-2*legend], .5);
                y.domain(hits.map( function(d, i) { return d.hitId; } ));

                /* Kept for future.
                var color = d3.scale.linear()
                            .domain((hits.map( function(d) { return d.hitId; } )).reverse())
                            .range(["red", "yellow", "green"]);
                */
                var color2 = d3.scale.ordinal()
                                .domain((hits.map( function(d) { return d.hitId; } )))
                                .rangeBands([10,150], 0.5);

                var t = svg.append('g').attr('transform', 'translate(0, '+(2*margin-legend)+')')
                    .selectAll('.hits')
                    .data(hits)
                    .enter()
                    .append('g')//.attr('transform', function(d,i) {
                        //return 'translate(0, '+y(d.hitId)+')';
                    //})
                    .each( function(d,i) {
                        var h_i = i+1;
                        /*
                        var color_hsp = d3.scale.ordinal()
                                        .domain((d.map( function(d) { return d.hspId; } )))
                                        .range(["blue", "red", "green", "yellow", "orange"]);
                        */
                        var p_hsp = d;
                        var p_id = d.hitId;
                        var p_count = d.length;

                        d3.select(this)
                            .selectAll('.hsps')
                            .data(d).enter()
                            .append('a')
                        .each( function(pd, j) {
                            //console.log(d3.select(this.parentNode).datum().hitId);
                            //
                            var y_hspline = y(p_id)+barheight/2;
                            var hspline_color = d3.rgb(color2(p_id),color2(p_id),color2(p_id));

                            if (j+1 < p_count) {
                                if( p_hsp[j].hspEnd < p_hsp[j+1].hspStart ) {
                                    d3.select(this.parentNode).append('line')
                                        .attr('x1', x(p_hsp[j].hspEnd))
                                        .attr('y1', y_hspline)
                                        .attr('x2', x(p_hsp[j+1].hspStart))
                                        .attr('y2', y_hspline)
                                        .attr('stroke', hspline_color);
                                }
                                else if ( p_hsp[j].hspStart > p_hsp[j+1].hspEnd ) {
                                    d3.select(this.parentNode).append('line')
                                        .attr('x1', x(p_hsp[j+1].hspEnd))
                                        .attr('y1', y_hspline)
                                        .attr('x2', x(p_hsp[j].hspStart))
                                        .attr('y2', y_hspline)
                                        .attr('stroke', hspline_color);
                                };
                            };

                            d3.select(this)//.append('a')
                            .attr('xlink:href', function(d,i) {return '#Query_'+(q_i)+'_hit_'+(h_i);})
                            .append('rect')
                            .attr('x', function(d) {
                                if(d.hspFrame < 0)
                                    return x(d.hspStart);
                                else
                                    return x(d.hspStart);
                            })
{'fraction_non_alphanumeric': 0.14559074993893006, 'fraction_numerical': 0.011562576337431804, 'mean_word_length': 0.8606271777003485, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 36, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3921738', 'n_tokens_mistral': 3368, 'n_tokens_neox': 3150, 'n_words': 508}