<commit_before>var ChartHandler = function(){
    var _self = this;

    _self.fn = {
        getDataAndLabels: function(){
            var usage = dataModel.memory();
            var dataset = [];
            var labels = [];
            for(var i = 0, ii = usage.length; i < ii; i++){
                var date = new Date(parseInt(usage[i].time));
                var hours = date.getHours();
                if(hours < 10) hours = "0"+hours;
                var minutes = date.getMinutes();
                if(minutes < 10) minutes = "0" + minutes;
                labels.push("       "+hours + ":" + minutes);
                dataset.push((parseInt(usage[i].memory.split(":")[0])/1024).toFixed(2));
            }
            return {data: dataset, labels: labels};
        },
        getOptions: function(data){
            var min = Math.max.apply(Math, data);
            var max = Math.min.apply(Math, data);

            if (max == min) {
                //Chart.js screws up if all the data on a line is the same, this is a workaround.
                return {
                    animation: false,
                    scaleOverride: true,
                    scaleSteps: 3,
                    scaleStepWidth: 1,
                    scaleStartValue: max-2,
                    scaleLabel: "<%=value%> MB"
                };
            }
            return {
                animation: false,
                scaleLabel: "<%=value%> MB"
            };
        },
        subscribe: function(){
            var ctx = $("#memoryChart").get(0).getContext("2d");
            dataModel.memory.subscribe(function(){
                ctx.canvas.width = 350;<commit_msg>Fixed chart label. Was saying what was actually KB was MB.<commit_after>var ChartHandler = function(){
    var _self = this;

    _self.usingMegabytes = false;

    _self.fn = {
        getDataAndLabels: function(){
            var usage = dataModel.memory();
            var dataset = [];
            var labels = [];
            for(var i = 0, ii = usage.length; i < ii; i++){
                var date = new Date(parseInt(usage[i].time));
                var hours = date.getHours();
                if(hours < 10) hours = "0"+hours;
                var minutes = date.getMinutes();
                if(minutes < 10) minutes = "0" + minutes;
                labels.push("       "+hours + ":" + minutes);
                if(_self.usingMegabytes){
                    dataset.push(((parseInt(usage[i].memory.split(":")[0])/1024/1024)).toFixed(2));
                }else{
                    var value = (parseInt(usage[i].memory.split(":")[0])/1024);
                    if(value > 1024){
                        _self.usingMegabytes = true;
                        value /= 1024;
                    }
                    dataset.push((value).toFixed(2));
                }
            }
            return {data: dataset, labels: labels};
        },
        getOptions: function(data){
            var min = Math.max.apply(Math, data);
            var max = Math.min.apply(Math, data);

            var options = {};

            var scaleLabel = "<%=value%> " + (_self.usingMegabytes ? "MB" : "KB");

            if (max == min) {
                //Chart.js screws up if all the data on a line is the same, this is a workaround.
                options = {
                    animation: false,
                    scaleOverride: true,
                    scaleSteps: 3,
                    scaleStepWidth: 1,
                    scaleStartValue: max-2,
                    scaleLabel: scaleLabel
                };
            }else{
                options = {
                    animation: false,
                    scaleLabel: scaleLabel
                };
            }
            _self.usingMegabytes = false;
            return options;
        },
        subscribe: function(){
            var ctx = $("#memoryChart").get(0).getContext("2d");
            dataModel.memory.subscribe(function(){
                ctx.canvas.width = 350;
{'fraction_non_alphanumeric': 0.125, 'fraction_numerical': 0.014940239043824702, 'mean_word_length': 1.256741573033708, 'pattern_counts': {'":': 5, '<': 12, '<?xml version=': 0, '>': 7, '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': '1748761', 'n_tokens_mistral': 1118, 'n_tokens_neox': 1008, 'n_words': 254}