<commit_before>// This is the boilerplate file
// it should be used as a base for every module
define([
  'jquery',
  'underscore',
  'backbone',
  'models/relay',
  'models/graph',
  'text!templates/details/main.html',
  'tooltip',
  'popover',
  'flot',
  'canvas2img',
  'collapse',
  'helpers'
], function($, _, Backbone, relayModel, graphModel, mainDetailsTemplate){
    var mainDetailsView = Backbone.View.extend({
        el: $("#content"),
        initialize: function() {
           this.model = new relayModel;
           this.graph = new graphModel;
           //console.log(this.graph);
           $("#loading").show();
        },
        render: function() {
            var data = {relay: this.model};
            //console.log(data);
            var compiledTemplate = _.template(mainDetailsTemplate, data);
            this.el.html(compiledTemplate);
            var graph = this.graph;
            this.graph.lookup(this.model.fingerprint, {
                success: function() {
                    graph.parsebwdata(graph.data);
                    //console.log(graph.get('days').write);
                    function showTooltip(x, y, contents) {
                        $('<div id="graphtooltip">' + contents + '</div>').css( {
                            position: 'absolute',
                            display: 'none',
                            top: y - 25,
                            left: x + 5,
                            border: '1px solid #fdd',
                            padding: '2px',
                            'background-color': '#fee',
                            opacity: 0.80
                        }).appendTo("body").fadeIn(200);
                    }
                    graphs = ['days', 'week', 'month',
                            'months', 'year', 'years'];
                    _.each(graphs, function(g) {
                        var plot_data = [{data: graph.get(g).write, label: 'write'},
                                         {data: graph.get(g).read, label: 'read'}];
                        $.plot($("#"+g),
                            plot_data, {
                                series: {
                                    lines: {show: true},
                                    points: {show: true},
                                    },
                                grid: { hoverable: true, clickable: true },
                                xaxis: {mode: 'time', tickLength: 5},
                        });
                        $("#"+g).resize();


                        $("#save_"+g).attr('href', Canvas2Image.saveAsPNG($("#"+g+" > canvas.base")[0], false));

                        var previousItem = null;
                        $("#"+g).bind("plothover", function (event, pos, item){
                            if (item) {
                                if (previousItem != item.dataIndex) {
                                    previousItem = item.dataIndex;

                                    $("#graphtooltip").remove();
                                    var x = item.datapoint[0].toFixed(2),
                                        y = item.datapoint[1].toFixed(2);
                                    var bw = hrBandwidth(item.datapoint[1]);
                                    showTooltip(item.pageX, item.pageY,
                                                bw);

                                }
                            } else {
                                $("#graphtooltip").remove();
                                previousItem = null;
                            }
                        });
                    });<commit_msg>Indicate on y axis whether values are B/s, KB/s, or MB/s.<commit_after>// This is the boilerplate file
// it should be used as a base for every module
define([
  'jquery',
  'underscore',
  'backbone',
  'models/relay',
  'models/graph',
  'text!templates/details/main.html',
  'tooltip',
  'popover',
  'flot',
  'canvas2img',
  'collapse',
  'helpers'
], function($, _, Backbone, relayModel, graphModel, mainDetailsTemplate){
    var mainDetailsView = Backbone.View.extend({
        el: $("#content"),
        initialize: function() {
           this.model = new relayModel;
           this.graph = new graphModel;
           //console.log(this.graph);
           $("#loading").show();
        },
        render: function() {
            var data = {relay: this.model};
            //console.log(data);
            var compiledTemplate = _.template(mainDetailsTemplate, data);
            this.el.html(compiledTemplate);
            var graph = this.graph;
            this.graph.lookup(this.model.fingerprint, {
                success: function() {
                    graph.parsebwdata(graph.data);
                    //console.log(graph.get('days').write);
                    function showTooltip(x, y, contents) {
                        $('<div id="graphtooltip">' + contents + '</div>').css( {
                            position: 'absolute',
                            display: 'none',
                            top: y - 25,
                            left: x + 5,
                            border: '1px solid #fdd',
                            padding: '2px',
                            'background-color': '#fee',
                            opacity: 0.80
                        }).appendTo("body").fadeIn(200);
                    }
                    graphs = ['days', 'week', 'month',
                            'months', 'year', 'years'];
                    _.each(graphs, function(g) {
                        var plot_data = [{data: graph.get(g).write, label: 'write'},
                                         {data: graph.get(g).read, label: 'read'}];
                        $.plot($("#"+g),
                            plot_data, {
                                series: {
                                    lines: {show: true},
                                    points: {show: true},
                                    },
                                grid: { hoverable: true, clickable: true },
                                xaxis: {mode: 'time', tickLength: 5},
                                yaxis: {tickFormatter : function suffixFormatter(val, axis) {
                                if (val > 1000000)
                                   return (val / 1000000).toFixed(axis.tickDecimals) + "&nbsp;MB/s";
                                else if (val > 1000)
                                   return (val / 1000).toFixed(axis.tickDecimals) + "&nbsp;KB/s";
                                else
                                   return val.toFixed(axis.tickDecimals) + "&nbsp;B/s";
                                }},
                        });
                        $("#"+g).resize();


                        $("#save_"+g).attr('href', Canvas2Image.saveAsPNG($("#"+g+" > canvas.base")[0], false));

                        var previousItem = null;
                        $("#"+g).bind("plothover", function (event, pos, item){
                            if (item) {
                                if (previousItem != item.dataIndex) {
                                    previousItem = item.dataIndex;

                                    $("#graphtooltip").remove();
                                    var x = item.datapoint[0].toFixed(2),
                                        y = item.datapoint[1].toFixed(2);
                                    var bw = hrBandwidth(item.datapoint[1]);
                                    showTooltip(item.pageX, item.pageY,
                                                bw);

                                }
                            } else {
                                $("#graphtooltip").remove();
                                previousItem = null;
                            }
                        });
                    });
{'fraction_non_alphanumeric': 0.12617296474765408, 'fraction_numerical': 0.007862033984275933, 'mean_word_length': 0.9450061652281134, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 36, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6056141', 'n_tokens_mistral': 1952, 'n_tokens_neox': 1831, 'n_words': 378}