<commit_before>//This code is heavily based on code from 
//http://mbostock.github.io/d3/talk/20111018/tree.html 

d3.queue = function(d3, canvasID, w, h, data) {

    var spacing = w / data.length;
    var defaultSize = 15;

    var chart = d3.select(".chart").append("svg")
        .attr("width", w)
        .attr("height", h)

    var nodes = chart.selectAll("g")
        .data(data)
        .enter().append("g")
        .attr("transform", function(d, i) {
            size = d.size || defaultSize;
            return "translate(" + 
                i*spacing+","+(h/2 - size/2)+")";
        })

    nodes.append("rect")
        .attr("height", function(d) {
            return d.size || defaultSize;
        })
        .attr("width", function(d) {
            return d.size || defaultSize;
        })
        .style("fill", function (d) {
            return d.color || "steelblue"  
        })
        .style("stroke", "gray")
        .style("stroke-width", 2)
    
    nodes    
        .append("text")
            .text(function(d) { return d.name})
            .attr("x", 0)
            .attr("y", function(d) {return 15+ (d.size||defaultSize)})
            .attr("dy", ".35em") 

        
    links = []

    for (i = 1; i < data.length; i++) {
        links.push({
            x2: data[i].size || defaultSize,
            x1: data[i - 1].size || defaultSize
        })
    }

    var lines = chart.selectAll("line")
        .data(links)
        .enter().append("line")
        .attr("x1", function(d, i) {
            return (i) * spacing + d.x1
        })
        .attr("x2", function(d, i) {
            return (i + 1) * spacing
        })
        .attr("y1", h / 2) 
        .attr("y2", h / 2)
        .style("stroke", "black")
}<commit_msg>clean up code - more compact<commit_after>//This code is heavily based on code from 
//http://mbostock.github.io/d3/talk/20111018/tree.html 

d3.queue = function(d3, canvasID, w, h, data) {

    var spacing = w / data.length;
    var defaultSize = 15;

    var chart = d3.select(".chart").append("svg")
        .attr("width", w)
        .attr("height", h)

    var nodes = chart.selectAll("g")
        .data(data)
        .enter().append("g")
        .attr("transform", function(d, i) {
            size = d.size || defaultSize;
            return "translate(" + 
                i*spacing+","+(h/2 - size/2)+")";
        })

    nodes.append("rect")
        .attr("height", function(d) {
            return d.size || defaultSize;
        })
        .attr("width", function(d) {
            return d.size || defaultSize;
        })
        .style("fill", function (d) {
            return d.color || "steelblue"  
        })
        .style("stroke", "gray")
        .style("stroke-width", 2)
    
    nodes    
        .append("text")
            .text(function(d) { return d.name})
            .attr("x", 0)
            .attr("y", function(d) {return 15+ (d.size||defaultSize)})
            .attr("dy", ".35em") 

    //we don't want to process the first node
    data.pop()

    var lines = chart.selectAll("line")
        .data(data)
        .enter().append("line")
        .attr("x1", function(d, i) {
            return (i) * spacing + d.size
        })
        .attr("x2", function(d, i) {
            return (i + 1) * spacing
        })
        .attr("y1", h / 2) 
        .attr("y2", h / 2)
        .style("stroke", "black")
}
{'fraction_non_alphanumeric': 0.18128136994390315, 'fraction_numerical': 0.018600531443755536, 'mean_word_length': 1.6041506533435819, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, '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': '465222', 'n_tokens_mistral': 1152, 'n_tokens_neox': 1084, 'n_words': 240}