<commit_before>if (typeof Perfcharts === "undefined")
    Perfcharts = {};

Perfcharts.eventHandlers = {
    toggleSeries : function(self, seriesIndex) {
        var $this = $(self);
        var $placeholder = $this.parents(".legend").siblings(".placeholder");

        var chart =  $placeholder.data("chart");
        var series = chart.series[seriesIndex];
        var show = false;
        if (series._show === false)
            show = true;
        series._show = show;

        if (!series.lines)
            series.lines = {
                show : true
            };
        series.lines.show = show ? series._showLines : false;

        if (!series.bars)
            series.bars = {
                show : false
            };
        series.bars.show = show ? series._showBars : false;

        if (!series.points)
            series.points = {
                show : false
            };
        series.points.show = show ? series._showPoints : false;

        redraw($placeholder, chart.plot, chart, true);
    }
};

//abstract class Painter
Perfcharts.Painter = function() {
};
Perfcharts.Painter.prototype = {
    paint : function($node, data) {
    }
};
Perfcharts.Painter.create = function (chart) {
    if (chart.chartType === "TABLE")
        return new Perfcharts.TablePainer();
    if (chart.xaxisMode === "BAR_STRING")
        return new Perfcharts.BarChartPainer();
    return new Perfcharts.FlotChartPainter();
};

// class TablePainer : Painter
Perfcharts.TablePainer = function() {
};
Perfcharts.TablePainer.prototype = new Perfcharts.Painter();

Perfcharts.TablePainer.prototype.paint = function($chart, chart) {
    function createTableCell(cell) {
    		var isFloat = cell.valueType === "double" || cell.valueType === "float";
    		var isNumber = isFloat || typeof cell.value === "number"
    				|| cell.valueType === "int" || cell.valueType === "long";
    		if (isNumber && cell.value !== null && cell.cssClass && cell.cssClass.indexOf("perfcharts-unit-ms2s") >= 0) {
    		    cell.value = parseFloat(cell.value) / 1000.0;
    		}
    		var showText = cell.value;
    		if (isFloat) {
    			showText = cell.value !== null ? cell.value.toFixed(3)
    					: (cell.rawValue === "NaN" ? "N/A" : cell.rawValue);
    		}
    		var $td = $("<td/>").text(showText);
    		if (cell.cssClass)
    			$td.addClass(cell.cssClass);
    		if (isNumber)
    			$td.css("text-align", "right");
    		return $td;
    }

    $chart.append($("<h3 class='perfcharts-title'/>").text(chart.title)).append(
    				$("<h4 class='perfcharts-subtitle'/>").text(chart.subtitle));
    		var $table_container = $("<div class='perfcharts-table-container'>")
    				.appendTo($chart);
    		var $table = $("<table/>").addClass("perfcharts-table table table-bordered table-striped table-hover").appendTo(
    				$table_container);
    		if (chart.key)
    			$table.attr("data-key", chart.key);
    		if (chart.header) {
    		    var $thead = $("<thead/>").appendTo($table);
    			var $tableHeaderRow = $("<tr/>").appendTo($thead);
    			for (var i = 0; i < chart.header.length; ++i) {
    				var $th = $("<th/>").text(chart.header[i]).appendTo($tableHeaderRow);
    				if (chart.headerTooltip && chart.headerTooltip[i])
    				    $th.attr('title', chart.headerTooltip[i]);
    				if (chart.columnWidths && chart.columnWidths[i] !== null)
                        $th.css('width', chart.columnWidths[i]);
    			}
    		}
    		if (chart.topRows) {
    			var $thead = $("<tbody class=\"tablesorter-no-sort\"/>").appendTo(
    					$table);<commit_msg>bugfix: time values change unexpectly in tables after navigating back from other charts<commit_after>if (typeof Perfcharts === "undefined")
    Perfcharts = {};

Perfcharts.eventHandlers = {
    toggleSeries : function(self, seriesIndex) {
        var $this = $(self);
        var $placeholder = $this.parents(".legend").siblings(".placeholder");

        var chart =  $placeholder.data("chart");
        var series = chart.series[seriesIndex];
        var show = false;
        if (series._show === false)
            show = true;
        series._show = show;

        if (!series.lines)
            series.lines = {
                show : true
            };
        series.lines.show = show ? series._showLines : false;

        if (!series.bars)
            series.bars = {
                show : false
            };
        series.bars.show = show ? series._showBars : false;

        if (!series.points)
            series.points = {
                show : false
            };
        series.points.show = show ? series._showPoints : false;

        redraw($placeholder, chart.plot, chart, true);
    }
};

//abstract class Painter
Perfcharts.Painter = function() {
};
Perfcharts.Painter.prototype = {
    paint : function($node, data) {
    }
};
Perfcharts.Painter.create = function (chart) {
    if (chart.chartType === "TABLE")
        return new Perfcharts.TablePainer();
    if (chart.xaxisMode === "BAR_STRING")
        return new Perfcharts.BarChartPainer();
    return new Perfcharts.FlotChartPainter();
};

// class TablePainer : Painter
Perfcharts.TablePainer = function() {
};
Perfcharts.TablePainer.prototype = new Perfcharts.Painter();

Perfcharts.TablePainer.prototype.paint = function($chart, chart) {
    function createTableCell(cell) {
    		var isFloat = cell.valueType === "double" || cell.valueType === "float";
    		var isNumber = isFloat || typeof cell.value === "number"
    				|| cell.valueType === "int" || cell.valueType === "long";
    	    var value = cell.value;
    		if (isNumber && cell.value !== null && cell.cssClass && cell.cssClass.indexOf("perfcharts-unit-ms2s") >= 0) {
    		    value = parseFloat(cell.value) / 1000.0;
    		}
    		//var showText = cell.value;
    		if (isFloat) {
    			value = value !== null ? value.toFixed(3)
    					: (cell.rawValue === "NaN" ? "N/A" : cell.rawValue);
    		}
    		var $td = $("<td/>").text(value);
    		if (cell.cssClass)
    			$td.addClass(cell.cssClass);
    		if (isNumber)
    			$td.css("text-align", "right");
    		return $td;
    }

    $chart.append($("<h3 class='perfcharts-title'/>").text(chart.title)).append(
    				$("<h4 class='perfcharts-subtitle'/>").text(chart.subtitle));
    		var $table_container = $("<div class='perfcharts-table-container'>")
    				.appendTo($chart);
    		var $table = $("<table/>").addClass("perfcharts-table table table-bordered table-striped table-hover").appendTo(
    				$table_container);
    		if (chart.key)
    			$table.attr("data-key", chart.key);
    		if (chart.header) {
    		    var $thead = $("<thead/>").appendTo($table);
    			var $tableHeaderRow = $("<tr/>").appendTo($thead);
    			for (var i = 0; i < chart.header.length; ++i) {
    				var $th = $("<th/>").text(chart.header[i]).appendTo($tableHeaderRow);
    				if (chart.headerTooltip && chart.headerTooltip[i])
    				    $th.attr('title', chart.headerTooltip[i]);
    				if (chart.columnWidths && chart.columnWidths[i] !== null)
                        $th.css('width', chart.columnWidths[i]);
    			}
    		}
    		if (chart.topRows) {
    			var $thead = $("<tbody class=\"tablesorter-no-sort\"/>").appendTo(
    					$table);
{'fraction_non_alphanumeric': 0.1658354114713217, 'fraction_numerical': 0.003047935716264893, 'mean_word_length': 2.4084041548630784, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '6002484', 'n_tokens_mistral': 2479, 'n_tokens_neox': 2328, 'n_words': 434}