<commit_before>angular.module('metadataViewerApp').directive('forceTree', ['tipService', 'StatsService', function(tipService, StatsService) {
    function link(scope, element, attrs) {
        var width = document.body.clientWidth - 50,
            color = d3.scale.category10(),
            tip = tipService.tipDiv();

        var provider = function(p) {
            switch (p) {
                case "dpla":
                    return "http://dp.la/search?q=";
                    break;
                case "euro":
                    return "http://www.europeana.eu/portal/search.html?query=";
                    break;
                case "digitalnz":
                    return "http://www.digitalnz.org/records?text=";
                    break;
                case "trove":
                    return "http://trove.nla.gov.au/result?q=";
                    break;
                default:
                    return "http://dp.la/search?q=";
            }
        };

        scope.$watchGroup(['data', 'chart'], function(values) {
            if(!values[0]) { return; }
            var data = values[0];
            var chart_type = values[1];

            /**
             * Format data
             * @type {{name: string, children: Array}}
             */
            var datas = {name: "root", "children": [] };
            var keys = [];

            data.forEach(function(d) {
                if(_.contains(keys, d.type) === false) {
                    datas.children.push({ "name": d.type, "children": []});
                    keys.push(d.type);
                }

                var i = _.indexOf(keys, d.type);
                datas.children[i].children.push(d);
            });

            keys = keys.sort();

            /**
             * Add the legend
             */
            var legend = d3.select(element[0])
                .append("svg")
                .attr("width", width)
                .attr("height", 55)
                .attr("transform", "translate(" + width/3.5 + ",0)");

            var j = 0;

            legend.selectAll('g').data(keys)
                .enter()
                .append('g').attr("width",190)
                .each(function(d) {
                    var g = d3.select(this);

                    g.append("rect")
                        .attr("x", j)
                        .attr("y", 15)
                        .attr("width", 10)
                        .attr("height", 10)
                        .style("fill", color(d));

                    g.append("text")
                        .attr("x", j + 15)
                        .attr("y", 25)
                        .attr("height",30)
                        .attr("width", d.length * 50)
                        .text(d);

                    j += (d.length * 5) + 50;
                });

            /**
             * Start the graphing
             */
             if(chart_type === 'tree') {
                treeMap();
             } else if(chart_type === 'cloud') {
                textCloud();
             } else {
                textCloud();
             }

            /**
             * Graph types
             */
            function textCloud() {
                var height = document.body.clientHeight - 25,
                    margin = { 'top':250, bottom: 25, left: 0, right: 25 };

                var zoom = d3.behavior.zoom()
                    .scaleExtent([1, 10])
                    .on("zoom", zooming);
<commit_msg>Set back to basic set.<commit_after>angular.module('metadataViewerApp').directive('forceTree', ['tipService', 'StatsService', function(tipService, StatsService) {
    function link(scope, element, attrs) {
        var width = document.body.clientWidth - 50,
            color = d3.scale.category10(),
            tip = tipService.tipDiv();

        var provider = function(p) {
            switch (p) {
                case "dpla":
                    return "http://dp.la/search?q=";
                    break;
                case "euro":
                    return "http://www.europeana.eu/portal/search.html?query=";
                    break;
                case "digitalnz":
                    return "http://www.digitalnz.org/records?text=";
                    break;
                case "trove":
                    return "http://trove.nla.gov.au/result?q=";
                    break;
                default:
                    return "http://dp.la/search?q=";
            }
        };

        scope.$watchGroup(['data', 'chart'], function(values) {
            if(!values[0]) { return; }
            var data = values[0];
            var chart_type = values[1];

            /**
             * Format data
             * @type {{name: string, children: Array}}
             */
            var datas = {name: "root", "children": [] };
            var keys = [];

            data.forEach(function(d) {
                if(_.contains(keys, d.type) === false) {
                    datas.children.push({ "name": d.type, "children": []});
                    keys.push(d.type);
                }

                var i = _.indexOf(keys, d.type);
                datas.children[i].children.push(d);
            });

            keys = keys.sort();

            /**
             * Add the legend
             */
            var legend = d3.select(element[0])
                .append("svg")
                .attr("width", width)
                .attr("height", 55)
                .attr("transform", "translate(" + width/3.5 + ",0)");

            var j = 0;

            legend.selectAll('g').data(keys)
                .enter()
                .append('g').attr("width",190)
                .each(function(d) {
                    var g = d3.select(this);

                    g.append("rect")
                        .attr("x", j)
                        .attr("y", 15)
                        .attr("width", 10)
                        .attr("height", 10)
                        .style("fill", color(d));

                    g.append("text")
                        .attr("x", j + 15)
                        .attr("y", 25)
                        .attr("height",30)
                        .attr("width", d.length * 50)
                        .text(d);

                    j += (d.length * 5) + 50;
                });

            /**
             * Start the graphing
             */
             if(chart_type === 'tree') {
                treeMap();
             } else if(chart_type === 'cloud') {
                textCloud();
             } else {
                treeMap();
             }

            /**
             * Graph types
             */
            function textCloud() {
                var height = document.body.clientHeight - 25,
                    margin = { 'top':250, bottom: 25, left: 0, right: 25 };

                var zoom = d3.behavior.zoom()
                    .scaleExtent([1, 10])
                    .on("zoom", zooming);

{'fraction_non_alphanumeric': 0.1434325996259531, 'fraction_numerical': 0.0146741476046612, 'mean_word_length': 0.988558352402746, 'pattern_counts': {'":': 14, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '6091918', 'n_tokens_mistral': 1943, 'n_tokens_neox': 1726, 'n_words': 348}