<commit_before>/**
 * Created by rerobins on 11/12/14.
 */

var d3Module = d3Module || angular.module('d3');

d3Module.directive('piechart', ['d3Service','$window', function(d3Service, $window) {

    function link(scope, element, attrs) {

        scope.render = function (data) {
            if (!scope.data) {
                return;
            }

            d3Service.get().then(function (d3) {

                /**
                 * data is :
                 *
                 * [{label: 'Some label', value: 100},..]
                 */

                console.log(scope.data);

                var svg = d3.select(element[0]);

                var width = parseInt(svg.style('width')),
                    height = parseInt(svg.style('height')),
                    radius = Math.min(width/2, height/2);

                var color = d3.scale.category10();

                var graphic = svg.append('g')
                    .data([scope.data])
                    .attr('transform', 'translate('+ (width/2) + ', ' + (height/2) + ')');

                var pie = d3.layout.pie()
                    .value(function(d) { return d.value; })
                    .sort(null)
                    .endAngle(-3.14 * 2);

                var arc = d3.svg.arc()
                    .outerRadius(radius * 0.8)
                    .innerRadius(0.4 * radius);

                var arcs = graphic.selectAll('g')
                    .data(pie)
                    .enter()
                    .append('g');

                arcs.append('path')
                    .attr('fill', function(d, i) {
                        return color(i);
                    }).attr('d', function(d) {
                       return arc(d);
                    });
                // add the text
                arcs.append("svg:text")
                    .attr("transform", function(d){
                        d.innerRadius = 0;
                        d.outerRadius = radius;
                        return "translate(" + arc.centroid(d) + ")";
                    }).attr("text-anchor", "middle")
                    .text( function(d, i) {
                        return data[i].value;
                    }
                );
            });
        };

        scope.$watch(function() {
            return element[0].offsetWidth;
        }, function() {
            scope.render(scope.data);
        });

        scope.$watch('data', function (newVals, oldVals) {
            console.log("data has been updated", newVals);
            return scope.render(newVals);
        }, true);
    }

    return {
        link: link,
        scope: {
            data: '='
        }
    }

}]);<commit_msg>Fix jshint issue.<commit_after>/**
 * Created by rerobins on 11/12/14.
 */

var d3Module = d3Module || angular.module('d3');

d3Module.directive('piechart', ['d3Service','$window', function(d3Service, $window) {

    function link(scope, element, attrs) {

        scope.render = function (data) {
            if (!scope.data) {
                return;
            }

            d3Service.get().then(function (d3) {

                /**
                 * data is :
                 *
                 * [{label: 'Some label', value: 100},..]
                 */

                console.log(scope.data);

                var svg = d3.select(element[0]);

                var width = parseInt(svg.style('width')),
                    height = parseInt(svg.style('height')),
                    radius = Math.min(width/2, height/2);

                var color = d3.scale.category10();

                var graphic = svg.append('g')
                    .data([scope.data])
                    .attr('transform', 'translate('+ (width/2) + ', ' + (height/2) + ')');

                var pie = d3.layout.pie()
                    .value(function(d) { return d.value; })
                    .sort(null)
                    .endAngle(-3.14 * 2);

                var arc = d3.svg.arc()
                    .outerRadius(radius * 0.8)
                    .innerRadius(0.4 * radius);

                var arcs = graphic.selectAll('g')
                    .data(pie)
                    .enter()
                    .append('g');

                arcs.append('path')
                    .attr('fill', function(d, i) {
                        return color(i);
                    }).attr('d', function(d) {
                       return arc(d);
                    });
                // add the text
                arcs.append("svg:text")
                    .attr("transform", function(d){
                        d.innerRadius = 0;
                        d.outerRadius = radius;
                        return "translate(" + arc.centroid(d) + ")";
                    }).attr("text-anchor", "middle")
                    .text( function(d, i) {
                        return data[i].value;
                    }
                );
            });
        };

        scope.$watch(function() {
            return element[0].offsetWidth;
        }, function() {
            scope.render(scope.data);
        });

        scope.$watch('data', function (newVals, oldVals) {
            console.log("data has been updated", newVals);
            return scope.render(newVals);
        }, true);
    }

    return {
        link: link,
        scope: {
            data: '='
        }
    };

}]);
{'fraction_non_alphanumeric': 0.14389561975768872, 'fraction_numerical': 0.014165890027958993, 'mean_word_length': 1.0559386973180076, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7629766', 'n_tokens_mistral': 1513, 'n_tokens_neox': 1380, 'n_words': 262}