<commit_before>function ColorMapService() {

    //blue to red gradient for environmental variables
    function tempColor(index, count, min, max ) {
        hue1 = 240 - (((index - min) / (max - min)) * 240);
        hue = (hue1 - 240);
        return 'hsl('+hue+',100%, 50%)';
    }

    //normal gradient
    function mapColor(index, count) {
        hue = 240 -  (index / count)*240;
        return 'hsl(' + hue + ',100%,50%)';
    }
    
    function mapColorMonochrome(min, max, value) {
        var lum = (value-min)/(max-min) * 95;
        return 'hsl(0, 65%,'+lum+'%)'; //RED hue - can be changed
    }

    this.generateColorMap = function(results) {
        var colors = {};
        for (var i = 0; i < results.societies.length; i++) {
            var society = results.societies[i];
                for (var j = 0; j < society.environmental_values.length; j++) {
                    variable = results.environmental_variables.filter(function(env_var) {
                        return env_var.id == society.environmental_values[j].variable;
                    });
                    if (variable.length > 0) {
                        var color = tempColor(society.environmental_values[0].value, results.environmental_variables[0].range, results.environmental_variables[0].min, results.environmental_variables[0].max);
                        colors[society.society.id] = color;
                    }    
                }
            
            for (var j = 0; j < society.variable_coded_values.length; j++) {
                if (society.variable_coded_values[j].code_description && (society.variable_coded_values[j].code_description.description.indexOf("Missing data") != -1))
                    colors[society.society.id] = 'hsl(0, 0%, 100%)';
                else if (society.bf_cont_var) {
                    var color = mapColorMonochrome(results.code_ids[society.variable_coded_values[j].variable].min, results.code_ids[society.variable_coded_values[j].variable].max, society.variable_coded_values[j].coded_value);
                    colors[society.society.id] = color;
                } else {
                    var color = mapColor(society.variable_coded_values[j].coded_value, results.code_ids[society.variable_coded_values[j].variable].length);
                    colors[society.society.id] = color;
                }
            }
            
            if (society.language_family) {
                var color = mapColor(society.language_family, society.num_classifications);
                colors[society.society.id] = color;
            }
        }
        return colors;
    };
}
<commit_msg>Fixing gradients<commit_after>function ColorMapService() {

    //blue to red gradient for environmental variables
    function tempColor(index, min, max, id ) {
    if (id == 34 || id == 36) {
        hue = 30 + (((index - min) / (max - min)) * 88);
    } else if (id == 27){
        color = mapColorMonochrome(min, max, index, 252);
        return color;
    }
    else {
    hue = 240 - (((index - min) / (max - min))*240);
    }
        return 'hsl('+hue+',100%, 50%)';
    }

    //normal gradient
    function mapColor(index, count) {
        hue = 240 -  (index / count)*240;
        return 'hsl(' + hue + ',100%,50%)';
    }
    
    function mapColorMonochrome(min, max, value, color) {
        var lum = (((value-min)/(max-min))) * 95;
        lum = 100 - lum;
        return 'hsl('+color+', 65%,'+lum+'%)'; //RED hue - can be changed
    }

    this.generateColorMap = function(results) {
        var colors = {};
        for (var i = 0; i < results.societies.length; i++) {
            var society = results.societies[i];
                for (var j = 0; j < society.environmental_values.length; j++) {
                    variable = results.environmental_variables.filter(function(env_var) {
                        return env_var.id == society.environmental_values[j].variable;
                    });
                    if (variable.length > 0) {
                        var color = tempColor(society.environmental_values[0].value,  results.environmental_variables[0].min, results.environmental_variables[0].max, results.environmental_variables[0].id);
                        colors[society.society.id] = color;
                    }    
                }
            
            for (var j = 0; j < society.variable_coded_values.length; j++) {
                if (society.variable_coded_values[j].code_description && (society.variable_coded_values[j].code_description.description.indexOf("Missing data") != -1))
                    colors[society.society.id] = 'hsl(0, 0%, 100%)';
                else if (society.bf_cont_var) {
                    var color = mapColorMonochrome(results.code_ids[society.variable_coded_values[j].variable].min, results.code_ids[society.variable_coded_values[j].variable].max, society.variable_coded_values[j].coded_value, 0);
                    colors[society.society.id] = color;
                } else {
                    var color = mapColor(society.variable_coded_values[j].coded_value, results.code_ids[society.variable_coded_values[j].variable].length);
                    colors[society.society.id] = color;
                }
            }
            
            if (society.language_family) {
                var color = mapColor(society.language_family, society.num_classifications);
                colors[society.society.id] = color;
            }
        }
        return colors;
    };
}

{'fraction_non_alphanumeric': 0.12950819672131147, 'fraction_numerical': 0.018761384335154827, 'mean_word_length': 1.9553283100107643, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, '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': '1444205', 'n_tokens_mistral': 1716, 'n_tokens_neox': 1569, 'n_words': 298}