<commit_before>/*
 * bowling-webapp
 * https://github.com/MeerkatLabs/bowling-visualization
 *
 * Copyright (c) 2014 Meerkat Labs
 * http://www.meerkatlabsllc.com/
 * Licensed under the MIT License
 */

/**
 * Created by rerobins on 11/14/14.
 */
angular.module('d3').directive('horizbargraph', ['d3Service', function(d3Service) {

    var link = function(scope, element, attrs) {

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

            d3Service.get().then(function (d3) {
                var svg = d3.select(element[0]);
                var height = parseInt(svg.style('height')),
                    width = parseInt(svg.style('width'));

                var barWidth = width / scope.data.length;

                var yScale = d3.scale.linear()
                    .domain([0, d3.max(scope.data, function(d) {
                        return d.value;
                    })]).range([0, height]);

                var colors = d3.scale.category10();

                var bar = svg.selectAll('g')
                    .data(scope.data)
                    .enter().append("g")
                    .attr("transform", function(d, i) {
                        var location = (i * barWidth);
                        return "translate(" + location + "," + (height-yScale(d.value)) + ")";
                    });

                bar.append("rect")
                    .attr("width", barWidth - 1)
                    .attr("height", function(d) {
                        return yScale(d.value);
                    })
                    .style("fill", function(d,i) {
                        return colors(i);
                    });

            });
        };

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

        scope.$watch('data', function (newVals, oldVals) {
            return scope.render(newVals);
        }, true);
    };

    return {
        link: link,
        watch: {
            data: '='
        }
    };
}]);<commit_msg>It's Scope not watch in the return object for the directives.<commit_after>/*
 * bowling-webapp
 * https://github.com/MeerkatLabs/bowling-visualization
 *
 * Copyright (c) 2014 Meerkat Labs
 * http://www.meerkatlabsllc.com/
 * Licensed under the MIT License
 */

/**
 * Created by rerobins on 11/14/14.
 */
angular.module('d3').directive('horizbargraph', ['d3Service', function(d3Service) {

    var link = function(scope, element, attrs) {

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

            d3Service.get().then(function (d3) {
                var svg = d3.select(element[0]);
                var height = parseInt(svg.style('height')),
                    width = parseInt(svg.style('width'));

                var barWidth = width / scope.data.length;

                var yScale = d3.scale.linear()
                    .domain([0, d3.max(scope.data, function(d) {
                        return d.value;
                    })]).range([0, height]);

                var colors = d3.scale.category10();

                var bar = svg.selectAll('g')
                    .data(scope.data)
                    .enter().append("g")
                    .attr("transform", function(d, i) {
                        var location = (i * barWidth);
                        return "translate(" + location + "," + (height-yScale(d.value)) + ")";
                    });

                bar.append("rect")
                    .attr("width", barWidth - 1)
                    .attr("height", function(d) {
                        return yScale(d.value);
                    })
                    .style("fill", function(d,i) {
                        return colors(i);
                    });

            });
        };

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

        scope.$watch('data', function (newVals, oldVals) {
            return scope.render(newVals);
        }, true);
    };

    return {
        link: link,
        scope: {
            data: '='
        }
    };
}]);
{'fraction_non_alphanumeric': 0.14419915453264442, 'fraction_numerical': 0.012212306247064349, 'mean_word_length': 1.2947198275862069, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '7541472', 'n_tokens_mistral': 1233, 'n_tokens_neox': 1132, 'n_words': 218}