<commit_before>
(function(){
    // Simple perfect bar chart
    // -------------------------

    var BarChart = Datawrapper.Visualizations.BarChart = function() {

    };

    _.extend(BarChart.prototype, Datawrapper.Visualizations.RaphaelChart.prototype, {

        render: function(el) {
            el = $(el);

            this.setRoot(el);

            var me = this,
            sortBars = me.get('sort-values'),
            reverse = me.get('reverse-order'),
            useNegativeColor = me.get('negative-color', false),
            c = me.initCanvas({
                h: Math.max(me.getMaxChartHeight(el), 18 * 1.35 * me.chart.dataSeries().length)
            }),
            chart_width = c.w - c.lpad - c.rpad,
            series_gap = 0.05, // pull from theme
            row_gap = 0.01,
            row = 0, // pull from theme
            labelsInsideBars = me.get('labels-inside-bars', false);

            if (!_.isUndefined(me.get('selected-row'))) {
                row = me.get('selected-row');
            }
            if (row > me.chart.numRows() || row === undefined) row = 0;
            if (me.chart.numRows() > 1) me.chart.filterRow(row);

            me.init();
            me.initDimensions(0);

            $('.tooltip').hide();

            c.lastBarY = 0;

            _.each(me.chart.dataSeries(sortBars, reverse), function(series, s) {
                _.each(series.data, function(val, r) {
                    var d = me.barDimensions(series, s, r);
                    var fill = me.getSeriesColor(series, r, useNegativeColor),
                        stroke = d3.cie.lch(d3.rgb(fill)).darker(0.6).toString();
                    me.registerSeriesElement(c.paper.rect(d.x, d.y, d.w, d.h).attr({
                        'stroke': stroke,
                        'fill': fill
                    }).data('strokeCol', stroke), series);

                    var lbl_x = val >= 0 ?
                            c.zero - c.maxValueLabelWidth[0] - 10
                            : c.zero + c.maxValueLabelWidth[1] + 10,
                        lbl_align = val >= 0 ? 'right' : 'left',
                        val_x = val >= 0 ?
                            c.zero - c.maxValueLabelWidth[0]
                            : c.zero + c.maxValueLabelWidth[1],
                        val_align = val >= 0 ? 'left' : 'right',
                        lblClass = me.chart.hasHighlight() && me.chart.isHighlighted(series) ? ' highlighted' : '';

                    if (labelsInsideBars) {
                        lbl_x = val >= 0 ? d.x + 10 : d.x + d.w - 10;
                        val_x = val >= 0 ? d.x + d.w - 10 : d.x + 10;<commit_msg>bar charts: corrected left margin if labels are displayed inside bars<commit_after>
(function(){
    // Simple perfect bar chart
    // -------------------------

    var BarChart = Datawrapper.Visualizations.BarChart = function() {

    };

    _.extend(BarChart.prototype, Datawrapper.Visualizations.RaphaelChart.prototype, {

        render: function(el) {
            el = $(el);

            this.setRoot(el);

            var me = this,
            sortBars = me.get('sort-values'),
            reverse = me.get('reverse-order'),
            useNegativeColor = me.get('negative-color', false),
            c = me.initCanvas({
                h: Math.max(me.getMaxChartHeight(el), 18 * 1.35 * me.chart.dataSeries().length)
            }),
            chart_width = c.w - c.lpad - c.rpad,
            series_gap = 0.05, // pull from theme
            row_gap = 0.01,
            row = 0, // pull from theme
            labelsInsideBars = me.get('labels-inside-bars', false);

            if (!_.isUndefined(me.get('selected-row'))) {
                row = me.get('selected-row');
            }
            if (row > me.chart.numRows() || row === undefined) row = 0;
            if (me.chart.numRows() > 1) me.chart.filterRow(row);

            me.init();
            me.initDimensions(0);

            $('.tooltip').hide();

            c.lastBarY = 0;

            _.each(me.chart.dataSeries(sortBars, reverse), function(series, s) {
                _.each(series.data, function(val, r) {
                    var d = me.barDimensions(series, s, r);
                    var fill = me.getSeriesColor(series, r, useNegativeColor),
                        stroke = d3.cie.lch(d3.rgb(fill)).darker(0.6).toString();

                    if (labelsInsideBars) d.x -= 10;

                    me.registerSeriesElement(c.paper.rect(d.x, d.y, d.w, d.h).attr({
                        'stroke': stroke,
                        'fill': fill
                    }).data('strokeCol', stroke), series);

                    var lbl_x = val >= 0 ?
                            c.zero - c.maxValueLabelWidth[0] - 10
                            : c.zero + c.maxValueLabelWidth[1] + 10,
                        lbl_align = val >= 0 ? 'right' : 'left',
                        val_x = val >= 0 ?
                            c.zero - c.maxValueLabelWidth[0]
                            : c.zero + c.maxValueLabelWidth[1],
                        val_align = val >= 0 ? 'left' : 'right',
                        lblClass = me.chart.hasHighlight() && me.chart.isHighlighted(series) ? ' highlighted' : '';

                    if (labelsInsideBars) {
                        lbl_x = val >= 0 ? d.x + 10 : d.x + d.w - 10;
                        val_x = val >= 0 ? d.x + d.w - 10 : d.x + 10;
{'fraction_non_alphanumeric': 0.14790937557561246, 'fraction_numerical': 0.015840854669368208, 'mean_word_length': 1.2988992379339543, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '7052363', 'n_tokens_mistral': 1683, 'n_tokens_neox': 1537, 'n_words': 317}