<commit_before>﻿(function($) {
    var options = {
        zoombuttons: {
            enabled: false
        }
    };

	function init(plot) {
        var monthNames = [];
        var dayNames = [];
        var $buttons;
        var fadingIn = false;
        var fadingOut = false;
        var fadedIn = false;
        var moving = false;

        function createButtons () {
            $buttons = $('<div class="flot-zoom-buttons btn-group" />')
            .css({
                'display': 'none',
                'position': 'absolute',
                'left': '50%',
                'top': 0,
                'width': 140,
                'margin-left': -70
            });
            // var $trash = $('<button title="Verwijder data" class="btn btn-mini" type="button"><i class="icon-trash"></i></button>');
            // $buttons.append($trash);
            var $reset = $('<button title="Reset zoom" class="btn btn-mini" type="button"><i class="icon-refresh"></i></button>');
            $buttons.append($reset);
            var $plus = $('<button title="Zoom in" class="btn btn-mini" type="button"><i class="icon-zoom-in"></i></button>');
            $buttons.append($plus);
            var $min = $('<button title="Zoom uit" class="btn btn-mini" type="button"><i class="icon-zoom-out"></i></button>');
            $buttons.append($min);
            var $bwd = $('<button title="Schuif naar links" class="btn btn-mini" type="button"><i class="icon-backward"></i></button>');
            $buttons.append($bwd);
            var $fwd = $('<button title="Schuif naar rechts" class="btn btn-mini" type="button"><i class="icon-forward"></i></button>');
            $buttons.append($fwd);
            var $print = $('<button title="Print" class="btn btn-mini" type="button"><i class="icon-print"></i></button>');
            $buttons.append($print);

            // $trash.click(function () {
                // plot.removeAllDataUrls();
            // });
            $reset.click(function () {
                plot.setPreventUpdates(true);
                $.each(plot.getXAxes(), function (idx, axis) {
                    if (axis.datamin && axis.datamax) {
                        axis.options.min = null;
                        axis.options.max = null;
                    }
                    else {
                        // can't determine bounds from the data, so just
                        // pick sane ones
                        var today = new Date();
                        var lastYear = new Date(
                            today.getFullYear() - 1,
                            today.getMonth(),
                            today.getDate(),
                            today.getHours(),
                            today.getMinutes(),
                            today.getMilliseconds()
                        );
                        axis.options.min = lastYear.getTime();
                        axis.options.max = today.getTime();
                    }
                });
                $.each(plot.getYAxes(), function (idx, axis) {
                    if (axis.datamin && axis.datamax) {
                        axis.options.min = null;
                        axis.options.max = null;
                    }
                });
                plot.setupGrid();
                plot.draw();
                plot.setPreventUpdates(false);
            });
            $plus.click(function () {
                plot.zoom({ amount: 2 });
            });
            $min.click(function () {
                plot.zoom({ amount: 0.5 });
            });
            $bwd.click(function () {
                plot.pan({ left: -plot.width() / 3 });
            });
            $fwd.click(function () {
                plot.pan({ left: plot.width() / 3 });
            });
            $print.click(function () {
                if (Modernizr.canvas) {
                    // Copy the canvas, so we can set a white background.
                    // Then, open the graph as png in a new window, so
                    // it can be printed or copied to the clipboard.
                    var srcCanvas = $('canvas.flot-base', $(this).closest('div.graph-region'))[0];
                    var dstCanvas = document.createElement("canvas");
                    dstCanvas.width = srcCanvas.width + 200;
                    dstCanvas.height = srcCanvas.height;
                    var dstCtx = dstCanvas.getContext('2d');
                    dstCtx.fillStyle = "#FFFFFF";
                    dstCtx.fillRect(0, 0, dstCanvas.width, srcCanvas.height);
                    dstCtx.drawImage(srcCanvas, 0, 0);

                    // do get legend and draw on same canvas
                    var legends = $(this).closest('.graph-and-legend').find('.graph-legend');
                    for (var idx=0; idx < legends.length; idx++) {
                        var legend = legends[idx];
                        var color = $(legend).find('.legendcolor')  [0].style.borderColor;
                        var title = $(legend).find('h5')[0].title;
                        var position = {
                            x: srcCanvas.width,
                            y: 20 + (20 * idx)
                        };
                        dstCtx.rect(position.x - 20, position.y, 20, 20);
                        dstCtx.fillStyle = color;
                        dstCtx.fill();
                        dstCtx.fillStyle = 'black';
                        dstCtx.strokeStyle = 'black';
                        dstCtx.font = '10pt sans';
                        dstCtx.fillText(title, position.x + 5, position.y + 14);
                    }
<commit_msg>fix for position and color of legend<commit_after>﻿(function($) {
    var options = {
        zoombuttons: {
            enabled: false
        }
    };

	function init(plot) {
        var monthNames = [];
        var dayNames = [];
        var $buttons;
        var fadingIn = false;
        var fadingOut = false;
        var fadedIn = false;
        var moving = false;

        function createButtons () {
            $buttons = $('<div class="flot-zoom-buttons btn-group" />')
            .css({
                'display': 'none',
                'position': 'absolute',
                'left': '50%',
                'top': 0,
                'width': 140,
                'margin-left': -70
            });
            // var $trash = $('<button title="Verwijder data" class="btn btn-mini" type="button"><i class="icon-trash"></i></button>');
            // $buttons.append($trash);
            var $reset = $('<button title="Reset zoom" class="btn btn-mini" type="button"><i class="icon-refresh"></i></button>');
            $buttons.append($reset);
            var $plus = $('<button title="Zoom in" class="btn btn-mini" type="button"><i class="icon-zoom-in"></i></button>');
            $buttons.append($plus);
            var $min = $('<button title="Zoom uit" class="btn btn-mini" type="button"><i class="icon-zoom-out"></i></button>');
            $buttons.append($min);
            var $bwd = $('<button title="Schuif naar links" class="btn btn-mini" type="button"><i class="icon-backward"></i></button>');
            $buttons.append($bwd);
            var $fwd = $('<button title="Schuif naar rechts" class="btn btn-mini" type="button"><i class="icon-forward"></i></button>');
            $buttons.append($fwd);
            var $print = $('<button title="Print" class="btn btn-mini" type="button"><i class="icon-print"></i></button>');
            $buttons.append($print);

            // $trash.click(function () {
                // plot.removeAllDataUrls();
            // });
            $reset.click(function () {
                plot.setPreventUpdates(true);
                $.each(plot.getXAxes(), function (idx, axis) {
                    if (axis.datamin && axis.datamax) {
                        axis.options.min = null;
                        axis.options.max = null;
                    }
                    else {
                        // can't determine bounds from the data, so just
                        // pick sane ones
                        var today = new Date();
                        var lastYear = new Date(
                            today.getFullYear() - 1,
                            today.getMonth(),
                            today.getDate(),
                            today.getHours(),
                            today.getMinutes(),
                            today.getMilliseconds()
                        );
                        axis.options.min = lastYear.getTime();
                        axis.options.max = today.getTime();
                    }
                });
                $.each(plot.getYAxes(), function (idx, axis) {
                    if (axis.datamin && axis.datamax) {
                        axis.options.min = null;
                        axis.options.max = null;
                    }
                });
                plot.setupGrid();
                plot.draw();
                plot.setPreventUpdates(false);
            });
            $plus.click(function () {
                plot.zoom({ amount: 2 });
            });
            $min.click(function () {
                plot.zoom({ amount: 0.5 });
            });
            $bwd.click(function () {
                plot.pan({ left: -plot.width() / 3 });
            });
            $fwd.click(function () {
                plot.pan({ left: plot.width() / 3 });
            });
            $print.click(function () {
                if (Modernizr.canvas) {
                    // Copy the canvas, so we can set a white background.
                    // Then, open the graph as png in a new window, so
                    // it can be printed or copied to the clipboard.
                    var srcCanvas = $('canvas.flot-base', $(this).closest('div.graph-region'))[0];
                    var dstCanvas = document.createElement("canvas");
                    dstCanvas.width = srcCanvas.width + 200;
                    dstCanvas.height = srcCanvas.height;
                    var dstCtx = dstCanvas.getContext('2d');
                    dstCtx.fillStyle = "#FFFFFF";
                    dstCtx.fillRect(0, 0, dstCanvas.width, srcCanvas.height);
                    dstCtx.drawImage(srcCanvas, 0, 0);

                    // do get legend and draw on same canvas
                    var legends = $(this).closest('.graph-and-legend').find('.graph-legend');
                    for (var idx=0; idx < legends.length; idx++) {
                        var legend = legends[idx];
                        var color = $(legend).find('.legendcolor')[0].style.borderColor;
                        var title = $(legend).find('h5')[0].title;
                        var position = {
                            x: srcCanvas.width,
                            y: 30 + (20 * idx)
                        };
                        dstCtx.fillStyle = color;
                        dstCtx.fillRect(position.x - 5, position.y, 20, 20);
                        dstCtx.fillStyle = 'black';
                        dstCtx.strokeStyle = 'black';
                        dstCtx.font = '10pt sans';
                        dstCtx.fillText(title, position.x + 20, position.y + 14);
                    }

{'fraction_non_alphanumeric': 0.14222458377612468, 'fraction_numerical': 0.007438894792773645, 'mean_word_length': 1.211278637164676, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 61, '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': '259458', 'n_tokens_mistral': 3013, 'n_tokens_neox': 2798, 'n_words': 616}