<commit_before><!doctype html>
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
</head>
<body>


<script>
//TODO replace mock with real data
var data = {
    name: 'Animals',
    children: [
        {
            name: 'Mammals',
            children: [
                {name: "People"},
                {name: "Monkeys"},
                {name: "Rabbits"}
            ]
        },
        {
            name: 'Birds'
        },
    ]
};

var tree = d3.layout.tree().size([300,200])

var container = d3.select("body").append("svg")
    .style("width", "700px")
    .style("height", "800px")
    .append("g")
    .attr("transform", "translate(0,100)");



var nodes = tree.nodes(data);

container.selectAll("text")
    .data(nodes)
    .enter()
    .append("text")
        .text(function (d) { return d.name })
        .attr("x", function (d) {
            return d.x;
        })
        .attr("y", function (d) {
            return d.y;
        })

container.selectAll("path")
    .data(tree.links(nodes))
    .enter()
    .append("path")
    .attr("fill", "none")
    .attr("stroke", "black")
    .attr("d", d3.svg.diagonal())


</script>
</body>

</html><commit_msg>refactor and extend d3 visualisation<commit_after><!doctype html>
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
</head>
<body>

<button id="test" onclick="test()" style="position:fixed">Test</button>
<script>
//TODO replace mock with real data
var data = {
    name: 'Animals',
    children: [
        {
            name: 'Mammals',
            children: [
                {name: "People"},
                {name: "Monkeys"},
                {name: "Rabbits"}
            ]
        },
        {
            name: 'Birds'
        },
    ]
};

var data1 = {
    name: 'Animals',
    children: [
        {
            name: 'Mammals',
            children: [
                {name: "People"},
                {name: "Dogs"},
                {name: "Monkeys"},
                {name: "Rabbits"}
            ]
        },
        {
            name: 'Birds',
            children: {
                name: "Owl"
            }
        },
    ]
};


var tree = d3.layout.tree().size([600,200])

var container = d3.select("body").append("svg")
    .style("width", "700px")
    .style("height", "800px")
    .append("g")
    .attr("transform", "translate(0,100)");


function update (data) {
    var nodes = tree.nodes(data);//.reverse();


    var texts = container.selectAll("text")
        .data(nodes);

    texts.enter()
    .append("text")
        .text(function (d) { return d.name })
        .attr("x", function (d) {
            return d.x;
        })
        .attr("y", function (d) {
            return d.y;
        })

        texts.exit().remove();

        texts.attr("x", function (d) {
                        return d.x;
                    })
                    .attr("y", function (d) {
                        return d.y;
                    })


    var paths = container.selectAll("path")
            .data(tree.links(nodes));


    paths.enter()
    .append("path")
    .attr("fill", "none")
    .attr("stroke", "black")
    .attr("d", d3.svg.diagonal())

    paths.exit().remove();

    paths.attr("d", d3.svg.diagonal())
}

update(data);

function test() {
    data1.children[0].children.push({
        name: "Cats"
    })
    update(data1)
}

</script>
</body>

</html>
{'fraction_non_alphanumeric': 0.18896028037383178, 'fraction_numerical': 0.015186915887850467, 'mean_word_length': 1.6265337423312884, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, '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': '3290754', 'n_tokens_mistral': 1181, 'n_tokens_neox': 1121, 'n_words': 214}