<commit_before>Polymer({
    is: 'bullet-chart',
    properties: {
        title: '',
        inputs: {
            notify: true,
            type: Array,
            value: [{
                input: 'title',
                txt: 'Title',
                selectedValue: -1,
                uitype: 'single-value',
                selectedObjs: [],
                scaleType: '',
                format: '',
                maxSelectableValues: 1
            }, {
                input: 'subtitle',
                txt: 'Subtitle',
                selectedValue: -1,
                uitype: 'single-value',
                selectedObjs: [],
                scaleType: '',
                format: '',
                maxSelectableValues: 2
            }, {
                input: 'range1',
                txt: 'Range1',
                selectedValue: -1,
                uitype: 'single-value',
                selectedObjs: [],
                scaleType: '',
                format: '',
                maxSelectableValues: 1
            }, {
                input: 'range2',
                txt: 'Range2',
                selectedValue: -1,
                uitype: 'single-value',
                selectedObjs: [],
                scaleType: '',
                format: '',
                maxSelectableValues: 1
            }, {
                input: 'range3',
                txt: 'Range3',
                selectedValue: -1,
                uitype: 'single-value',
                selectedObjs: [],
                scaleType: '',
                format: '',
                maxSelectableValues: 1
            }, {
                input: 'measure1',
                txt: 'Measure 1',
                selectedValue: -1,
                uitype: 'single-value',
                selectedObjs: [],
                scaleType: '',
                format: '',
                maxSelectableValues: 1
            }, {
                input: 'measure2',
                txt: 'Measure 2',
                selectedValue: -1,
                uitype: 'single-value',
                selectedObjs: [],
                scaleType: '',
                format: '',
                maxSelectableValues: 1
            }, {
                input: 'marker',
                txt: 'Marker',
                selectedValue: -1,
                uitype: 'single-value',
                selectedObjs: [],
                scaleType: '',
                format: '',
                maxSelectableValues: 1
            }]
        },
        settings: {
            notify: true,
            type: Array,
            value: []
        },
        hideSettings: true,
        source: {
            type: Array,
            value: []
        },
        data: {
            type: Array,
            value: []
        },
        external: Array,
        svg: Object,
        sourceChanged: false
    },

    behaviors: [
        PolymerD3.chartBehavior,
        PolymerD3.colorPickerBehavior
    ],
    attached: function() {
        me = this;

        function callme(data) {
            me.source = data;
        }
        PolymerD3.fileReader('bullets.csv', [2,3,4,5,6,7], [], undefined, callme);
        me.inputs[0].selectedValue = 0;
        me.inputs[1].selectedValue = 1;
        me.inputs[2].selectedValue = 2;
        me.inputs[3].selectedValue = 3;
        me.inputs[4].selectedValue = 4;
        me.inputs[5].selectedValue = 5;
        me.inputs[6].selectedValue = 6;
        me.inputs[7].selectedValue = 7;
    },


    _toggleView: function() {
        this.hideSettings = !this.hideSettings;
    },

    draw: function() {
        var me = this;
        if (me.getInputsProperty('title') === -1 ||
            me.getInputsProperty('range1') === -1 ||
            me.getInputsProperty('range2') === -1 ||
              me.getInputsProperty('range3') === -1 ||
            me.getInputsProperty('measure1') === -1 ||
            me.getInputsProperty('measure2') === -1 ||
            me.getInputsProperty('marker') === -1) {
            throw new Error('Inputs not selected');
        }

        var margin = me.getMargins();
        
        me._prepareData();
        var bulletHeight = (this.chartHeight / me.data.length) - margin.top;
        var chart = d3.bullet()
            .width(this.chartWidth)
            .height(bulletHeight);

        // To remove previously initialized SVG
        // Bullet chart needs 5 svg elems, previous elements causes some problems in  rendering

        shift = function(charts) {
          var scale = d3.scale.linear();
          scale.range([0, me.chartHeight]);
          scale.domain([0, charts]);
          var bI = 0; var tI = 0; var sI = 0;
          return (type)=>{
            var m = {
             'bullet':scale(bI++),
             'title':scale(tI++)
           }
           console.log("tI" + tI +": "+type + " bI:" + bI);
           return m[type];
          };
        }(me.data.length);

        translateBulletG = function(){
          var tt = shift('bullet');
          str = "translate(" + 0 + "," + tt + ")";
          console.log("tt= >" + str + "<" + tt);
          return str;
        }
        translateTitleG = function(){
         var tt = shift('title');
          str = "translate(" + 0 + "," + tt + ")";
          console.log("titleG= >" + str + "<" + tt);
          return str; 
        }

        var bulletSVG = this.parentG.selectAll('g').data(me.data);
            
        bulletSVG.enter()
            .append("g")
            .attr("class", "bulletG")
            .attr('transform', translateBulletG)
            .append("svg")
            .attr("class", "bullet")
            .call(chart);

        var title = bulletSVG.enter()
            .append("g")
            .style("text-anchor", "end")
            .attr("class", "titleG")
            .attr("transform", translateTitleG);

        title.append("text")
            .attr("class", "title")
            .text(function(d) {
                return d.title;
            });

        title.append("text")
            .attr("class", "subtitle")
            .attr("dy", "1em")
            .text(function(d) {
                return d.subtitle;
            });<commit_msg>title and sub title are in proper place<commit_after>Polymer({
    is: 'bullet-chart',
    properties: {
        title: '',
        inputs: {
            notify: true,
            type: Array,
            value: [{
                input: 'title',
                txt: 'Title',
                selectedValue: -1,
                uitype: 'single-value',
                selectedObjs: [],
                scaleType: '',
                format: '',
                maxSelectableValues: 1
            }, {
                input: 'subtitle',
                txt: 'Subtitle',
                selectedValue: -1,
                uitype: 'single-value',
                selectedObjs: [],
                scaleType: '',
                format: '',
                maxSelectableValues: 2
            }, {
                input: 'range1',
                txt: 'Range1',
                selectedValue: -1,
                uitype: 'single-value',
                selectedObjs: [],
                scaleType: '',
                format: '',
                maxSelectableValues: 1
            }, {
                input: 'range2',
                txt: 'Range2',
                selectedValue: -1,
                uitype: 'single-value',
                selectedObjs: [],
                scaleType: '',
                format: '',
                maxSelectableValues: 1
            }, {
                input: 'range3',
                txt: 'Range3',
                selectedValue: -1,
                uitype: 'single-value',
                selectedObjs: [],
                scaleType: '',
                format: '',
                maxSelectableValues: 1
            }, {
                input: 'measure1',
                txt: 'Measure 1',
                selectedValue: -1,
                uitype: 'single-value',
                selectedObjs: [],
                scaleType: '',
                format: '',
                maxSelectableValues: 1
            }, {
                input: 'measure2',
                txt: 'Measure 2',
                selectedValue: -1,
                uitype: 'single-value',
                selectedObjs: [],
                scaleType: '',
                format: '',
                maxSelectableValues: 1
            }, {
                input: 'marker',
                txt: 'Marker',
                selectedValue: -1,
                uitype: 'single-value',
                selectedObjs: [],
                scaleType: '',
                format: '',
                maxSelectableValues: 1
            }]
        },
        settings: {
            notify: true,
            type: Array,
            value: []
        },
        hideSettings: true,
        source: {
            type: Array,
            value: []
        },
        data: {
            type: Array,
            value: []
        },
        external: Array,
        svg: Object,
        sourceChanged: false
    },

    behaviors: [
        PolymerD3.chartBehavior,
        PolymerD3.colorPickerBehavior
    ],
    attached: function() {
        me = this;

        function callme(data) {
            me.source = data;
        }
        PolymerD3.fileReader('bullets.csv', [2,3,4,5,6,7], [], undefined, callme);
        me.inputs[0].selectedValue = 0;
        me.inputs[1].selectedValue = 1;
        me.inputs[2].selectedValue = 2;
        me.inputs[3].selectedValue = 3;
        me.inputs[4].selectedValue = 4;
        me.inputs[5].selectedValue = 5;
        me.inputs[6].selectedValue = 6;
        me.inputs[7].selectedValue = 7;
    },


    _toggleView: function() {
        this.hideSettings = !this.hideSettings;
    },

    draw: function() {
        var me = this;
        if (me.getInputsProperty('title') === -1 ||
            me.getInputsProperty('range1') === -1 ||
            me.getInputsProperty('range2') === -1 ||
              me.getInputsProperty('range3') === -1 ||
            me.getInputsProperty('measure1') === -1 ||
            me.getInputsProperty('measure2') === -1 ||
            me.getInputsProperty('marker') === -1) {
            throw new Error('Inputs not selected');
        }

        var margin = me.getMargins();
        
        me._prepareData();
        var bulletHeight = (this.chartHeight / me.data.length) - margin.top;
        var chart = d3.bullet()
            .width(this.chartWidth)
            .height(bulletHeight);

        var bulletSVG = this.parentG.selectAll('g').data(me.data);
        var scaleB = d3.scale.linear();
          scaleB.range([0, me.chartHeight]);
          scaleB.domain([0, me.data.length]);
        var index = 0;    
        bulletSVG.enter()
            .append("g")
            .attr("class", "bulletG")
            .attr('transform', (d)=>{return "translate(" + 0 + "," + scaleB(index++) + ")";})
            .append("svg")
            .attr("class", "bullet")
            .call(chart);

        index = 0;
        var title = bulletSVG.enter()
            .append("g")
            .style("text-anchor", "end")
            .attr("class", "titleG")
            .attr("transform", (d)=>{return "translate(" + 0 + "," + (scaleB(index++) +(bulletHeight/2)) + ")";})

        title.append("text")
            .attr("class", "title")
            .text(function(d) {
                return d.title;
            });

        title.append("text")
            .attr("class", "subtitle")
            .attr("dy", "1em")
            .text(function(d) {
                return d.subtitle;
            });
{'fraction_non_alphanumeric': 0.13824211702036257, 'fraction_numerical': 0.012629951026720508, 'mean_word_length': 1.1680014900353883, 'pattern_counts': {'":': 1, '<': 5, '<?xml version=': 0, '>': 8, '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': '5081482', 'n_tokens_mistral': 3253, 'n_tokens_neox': 3045, 'n_words': 604}