<commit_before>var lg =  {

    mapRegister:'',
    _gridRegister:[],
    _colors:['#edf8fb','#b2e2e2','#66c2a4','#2ca25f','#006d2c'],
    _selectedBar:-1,

    init: function(){
        this.mapRegister.init();
        this._gridRegister.forEach(function(e){
           e.init(); 
        });       
    },

    colors:function(val){
        if(typeof val === 'undefined'){
            return this._colors;
        } else {
            this._colors=val;
            return this;
        }        
    },

    map: function(id){

        this._id = id;
        this._geojson = "";
        this._center = [0,0];
        this._zoom = 1;
        this._nameAttr = "";
        this._joinAttr = "";
        this._map = '';
        this._info = '';
        this._currentData =[];
        this._currentColumn = "";

        lg.mapRegister = this;

        this.geojson = function(val){
            if(typeof val === 'undefined'){
                return this._geojson;
            } else {
                this._geojson=val;
                return this;
            }        
        };

        this.center = function(val){
            if(typeof val === 'undefined'){
                return this._center;
            } else {
                this._center=val;
                return this;
            }        
        };


        this.zoom = function(val){
            if(typeof val === 'undefined'){
                return this._zoom;
            } else {
                this._zoom=val;
                return this;
            }        
        };

        this.joinAttr = function(val){
            if(typeof val === 'undefined'){
                return this._joinAttr;
            } else {
                this._joinAttr=val;
                return this;
            }        
        };

        this.nameAttr = function(val){
            if(typeof val === 'undefined'){
                return this._nameAttr;
            } else {
                this._nameAttr=val;
                return this;
            }        
        };

        this.onClick = function(val){
            if(typeof val === 'undefined'){
                return this._onClick;
            } else {
                this._onClick=val;
                return this;
            }
        }

        this.onHover = function(val){
            if(typeof val === 'undefined'){
                return this._onHover;
            } else {
                this._onHover=val;
                return this;
            }
        }                  

        this._style = function(feature){
            return {
                weight: 1,
                opacity: 0.8,
                color:'#000000',
                fillOpacity: 0.2,
                className: 'dashgeom dashgeom'+feature.properties[lg.mapRegister._joinAttr]
            };
        };

        this._onClick = function(feature){
            return feature;
        }

        this._onHover = function(feature){
            return feature;
        }        

        this.map = function(){
            return this._map;
        };                

        this.init = function(){
            this._map = this._initMap(this._id,this._geojson,this._center,this._zoom,this._joinAttr);
        };  

        this._initMap = function(id,geojson, center, zoom, joinAttr){

            var _parent = this;

            var baselayer = L.tileLayer('https://data.hdx.rwlabs.org/mapbox-base-tiles/{z}/{x}/{y}.png', {
                
            });

            var map = L.map(this._id.substring(1), {
                center: center,
                zoom: zoom,
                layers: [baselayer]
            });

            this._info = L.control();

            this._info.onAdd = function (map) {
                this._div = L.DomUtil.create('div', 'mapinfo');
                this.update();
                return this._div;
            };

            this._info.update = function (name, colName) {
                this._div.innerHTML = (name ? name: 'Hover a country for details');
                this._div.innerHTML = ((name && colName) ? (colName + '<br><p style="font-size: 16px; text-align:right;">' + name) : 'Select a grid column and hover a country for details');
            }

            this._info.addTo(map);

            var overlay = L.geoJson(geojson,{
                style: this._style,
                onEachFeature: onEachFeature
            }).addTo(map);                

            return map;

            function onEachFeature(feature, layer) {

                layer.on("mouseover",function(f,l){
                    columnName = _parent._currentColumn._labelName;
                    var currentData = findCurrentData(f.target.feature.properties[_parent._joinAttr]);
                    dataValue = _parent._currentColumn._labelAccessor(currentData.value);
                    _parent._info.update(f.target.feature.properties[_parent._nameAttr] + ' - ' + dataValue, columnName);
                    _parent._onHover(f.target.feature);

                    d3.selectAll('.horLine'+ currentData.pos +'id0').attr("opacity",1);
                    d3.selectAll('.horLine'+ currentData.pos +'id1').attr("opacity",1);
                    d3.selectAll('.horLine'+ currentData.pos +'id2').attr("opacity",1);
                    d3.selectAll('.dashgeom'+ currentData.key).attr("stroke-width",3);
                    d3.selectAll('.dashgeom'+ currentData.key).attr("fill-opacity",1);<commit_msg>fixed hovering map error when not data selected<commit_after>var lg =  {

    mapRegister:'',
    _gridRegister:[],
    _colors:['#edf8fb','#b2e2e2','#66c2a4','#2ca25f','#006d2c'],
    _selectedBar:-1,

    init: function(){
        this.mapRegister.init();
        this._gridRegister.forEach(function(e){
           e.init(); 
        });       
    },

    colors:function(val){
        if(typeof val === 'undefined'){
            return this._colors;
        } else {
            this._colors=val;
            return this;
        }        
    },

    map: function(id){

        this._id = id;
        this._geojson = "";
        this._center = [0,0];
        this._zoom = 1;
        this._nameAttr = "";
        this._joinAttr = "";
        this._map = '';
        this._info = '';
        this._currentData =[{key:'',value:"N/A",pos:""}];
        this._currentColumn = "";

        lg.mapRegister = this;

        this.geojson = function(val){
            if(typeof val === 'undefined'){
                return this._geojson;
            } else {
                this._geojson=val;
                return this;
            }        
        };

        this.center = function(val){
            if(typeof val === 'undefined'){
                return this._center;
            } else {
                this._center=val;
                return this;
            }        
        };


        this.zoom = function(val){
            if(typeof val === 'undefined'){
                return this._zoom;
            } else {
                this._zoom=val;
                return this;
            }        
        };

        this.joinAttr = function(val){
            if(typeof val === 'undefined'){
                return this._joinAttr;
            } else {
                this._joinAttr=val;
                return this;
            }        
        };

        this.nameAttr = function(val){
            if(typeof val === 'undefined'){
                return this._nameAttr;
            } else {
                this._nameAttr=val;
                return this;
            }        
        };

        this.onClick = function(val){
            if(typeof val === 'undefined'){
                return this._onClick;
            } else {
                this._onClick=val;
                return this;
            }
        }

        this.onHover = function(val){
            if(typeof val === 'undefined'){
                return this._onHover;
            } else {
                this._onHover=val;
                return this;
            }
        }                  

        this._style = function(feature){
            return {
                weight: 1,
                opacity: 0.8,
                color:'#000000',
                fillOpacity: 0.2,
                className: 'dashgeom dashgeom'+feature.properties[lg.mapRegister._joinAttr]
            };
        };

        this._onClick = function(feature){
            return feature;
        }

        this._onHover = function(feature){
            return feature;
        }        

        this.map = function(){
            return this._map;
        };                

        this.init = function(){
            this._map = this._initMap(this._id,this._geojson,this._center,this._zoom,this._joinAttr);
        };  

        this._initMap = function(id,geojson, center, zoom, joinAttr){

            var _parent = this;

            var baselayer = L.tileLayer('https://data.hdx.rwlabs.org/mapbox-base-tiles/{z}/{x}/{y}.png', {
                
            });

            var map = L.map(this._id.substring(1), {
                center: center,
                zoom: zoom,
                layers: [baselayer]
            });

            this._info = L.control();

            this._info.onAdd = function (map) {
                this._div = L.DomUtil.create('div', 'mapinfo');
                this.update();
                return this._div;
            };

            this._info.update = function (name, colName) {
                this._div.innerHTML = (name ? name: 'Hover a country for details');
                this._div.innerHTML = ((name && colName) ? (colName + '<br><p style="font-size: 16px; text-align:right;">' + name) : 'Select a grid column and hover a country for details');
            }

            this._info.addTo(map);

            var overlay = L.geoJson(geojson,{
                style: this._style,
                onEachFeature: onEachFeature
            }).addTo(map);                

            return map;

            function onEachFeature(feature, layer) {
                
                layer.on("mouseover",function(f,l){
                    var currentData = findCurrentData(f.target.feature.properties[_parent._joinAttr]);
                    if(_parent._currentColumn!=""){
                        columnName = _parent._currentColumn._labelName;
                        dataValue = _parent._currentColumn._labelAccessor(currentData.value);
                        _parent._info.update(f.target.feature.properties[_parent._nameAttr] + ' - ' + dataValue, columnName);
                        _parent._onHover(f.target.feature);
                    }

                    d3.selectAll('.horLine'+ currentData.pos +'id0').attr("opacity",1);
                    d3.selectAll('.horLine'+ currentData.pos +'id1').attr("opacity",1);
                    d3.selectAll('.horLine'+ currentData.pos +'id2').attr("opacity",1);
                    d3.selectAll('.dashgeom'+ currentData.key).attr("stroke-width",3);
                    d3.selectAll('.dashgeom'+ currentData.key).attr("fill-opacity",1);
{'fraction_non_alphanumeric': 0.1268217615642256, 'fraction_numerical': 0.00832805286503123, 'mean_word_length': 1.281701776125568, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '6853435', 'n_tokens_mistral': 3080, 'n_tokens_neox': 2875, 'n_words': 498}