<commit_before>function mapLegend(canvas) {

    var ctx = canvas.getContext("2d");
  //  ctx.fillRect(10, 10, 10, 10

    var canvasHeight=350;

    if (screen.height<400) {
        canvasHeight = screen.height * 0.6;
        canvas.height = canvasHeight;
    }

    ctx.font="15px Georgia";
    ctx.fillText("0",0,20);
    ctx.fillText("20",0,120);

    <%=ColorDrop.where layer_id:1%>
    <%=ColorDrop.all.to_json%>



    var my_gradient=ctx.createLinearGradient(0,0,0,canvasHeight-20);
    my_gradient.addColorStop(0,"red");
    my_gradient.addColorStop(0.2,"orange");
    my_gradient.addColorStop(0.4,"yellow");
    my_gradient.addColorStop(0.6,"green");
    my_gradient.addColorStop(0.8,"blue");
    my_gradient.addColorStop(1,"purple");
    ctx.fillStyle=my_gradient;
    ctx.fillRect(20,20,100,canvasHeight-20);
}<commit_msg>maplegend to use real values from database<commit_after>function mapLegend(canvas) {

    var ctx = canvas.getContext("2d");

    var canvasHeight=350;

    if (screen.height<400) {
        canvasHeight = screen.height * 0.6;
        canvas.height = canvasHeight;
    }

    ctx.font="15px Georgia";

    var colorsJSON = <%=(ColorDrop.where layer_id:1).to_json%>;
    var my_gradient=ctx.createLinearGradient(0,canvasHeight-20,0,0);


    var step = 1/colorsJSON.length;
    var counter = 0;
    var stepCounter = 0;

    colorsJSON.forEach(function(a)
    {
        if (a.value==0) {
            my_gradient.addColorStop((step * stepCounter), 'rgba(' + colorsJSON[counter].color + ')');
            ctx.fillText(colorsJSON[0].value,0,canvasHeight-2);
        }
        else {
            my_gradient.addColorStop((step * stepCounter), 'rgba(' + colorsJSON[counter].color + ',5)');
        }
        if (counter == colorsJSON.length/2>>0) {
            ctx.fillText(colorsJSON[counter].value,0,(canvasHeight-canvasHeight/colorsJSON.length*stepCounter)-20);
             console.log(canvasHeight-canvasHeight/colorsJSON.length*stepCounter);
        }
        if (counter == colorsJSON.length-1) {
            ctx.fillText(colorsJSON[counter].value,0,30);
        }

        console.log(a);
        counter++;
        stepCounter++;
    });








    ctx.fillStyle=my_gradient;
    ctx.fillRect(20,20,100,canvasHeight-20);
}
{'fraction_non_alphanumeric': 0.15050907481186365, 'fraction_numerical': 0.04293935369632581, 'mean_word_length': 3.02135231316726, 'pattern_counts': {'":': 0, '<': 8, '<?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': '6881240', 'n_tokens_mistral': 823, 'n_tokens_neox': 740, 'n_words': 100}