<commit_before>/**
 * @package     hubzero-cms
 * @file        plugins/time/summary/summary.js
 * @copyright   Copyright 2005-2014 Purdue University. All rights reserved.
 * @license     http://www.gnu.org/licenses/lgpl-3.0.html LGPLv3
 */

if (!jq) {
	var jq = $;
}

jQuery(document).ready(function( $ ) {
	// Fancy select boxes
	if (!!$.prototype.HUBfancyselect) {
		$('.plg_time_summary select').HUBfancyselect({
			'showSearch'         : true,
			'searchPlaceholder'  : 'seach...'
		});
	}

	// Date picker for date input field
	$(".hadDatepicker").datepicker({
		// Set a unix/MySQL friendly date format
		dateFormat: 'yy-mm-dd'
	});

	// Make clickable items clickable
	$('.clickable').click(function ( e ) {
		$(this).next('.respondable').slideToggle();
	});

	// Flot
	if ($('.charts').length) {
		var plot   = false;
		var data   = [];
		var mapped = [];
		var draw   = function () {
			$('.charts .tasks-bar').css({
				'width'  : $('.charts').width(),
				'height' : (data.length > 1) ? data.length*35 : 50
			});

			if (!plot) {
				var ticks  = [];
				var max    = 0;

				$.each(data, function ( i, val ) {
					mapped.push([val.hours, i]);
					ticks.push([i, val.pname]);
					if (parseFloat(val.hours, 10) > max) {
						max = val.hours;
					}
				});

				var options = {
					series: {
						bars: {
							show: true,
							barWidth: 0.6,
							align: "center",
							horizontal: true
						}
					},
					yaxis: {
						tickLength: 0,
						ticks: ticks
					},
					xaxis: {
						show: true,
						tickSize: Math.round(max / 10),
						tickFormatter: function formatter(val, axis) {
							if (val === 0) {
								return val + ' hours(s)';
							} else {
								return val;
							}
						}
					},
					grid: {
						borderColor: 'CCCCCC',
						borderWidth: 0,
						hoverable: true,
						clickable: true
					}
				};

				plot = $.plot('.charts .tasks-bar', [mapped], options);
			} else {
				plot.resize();
				plot.setupGrid();
				plot.setData([mapped]);
				plot.draw();
			}
		};<commit_msg>[PLG_TIME_SUMMARY] better default tick size for smaller numbers<commit_after>/**
 * @package     hubzero-cms
 * @file        plugins/time/summary/summary.js
 * @copyright   Copyright 2005-2014 Purdue University. All rights reserved.
 * @license     http://www.gnu.org/licenses/lgpl-3.0.html LGPLv3
 */

if (!jq) {
	var jq = $;
}

jQuery(document).ready(function( $ ) {
	// Fancy select boxes
	if (!!$.prototype.HUBfancyselect) {
		$('.plg_time_summary select').HUBfancyselect({
			'showSearch'         : true,
			'searchPlaceholder'  : 'seach...'
		});
	}

	// Date picker for date input field
	$(".hadDatepicker").datepicker({
		// Set a unix/MySQL friendly date format
		dateFormat: 'yy-mm-dd'
	});

	// Make clickable items clickable
	$('.clickable').click(function ( e ) {
		$(this).next('.respondable').slideToggle();
	});

	// Flot
	if ($('.charts').length) {
		var plot   = false;
		var data   = [];
		var mapped = [];
		var draw   = function () {
			$('.charts .tasks-bar').css({
				'width'  : $('.charts').width(),
				'height' : (data.length > 1) ? data.length*35 : 50
			});

			if (!plot) {
				var ticks  = [];
				var max    = 0;

				$.each(data, function ( i, val ) {
					mapped.push([val.hours, i]);
					ticks.push([i, val.pname]);
					if (parseFloat(val.hours, 10) > max) {
						max = val.hours;
					}
				});

				var options = {
					series: {
						bars: {
							show: true,
							barWidth: 0.6,
							align: "center",
							horizontal: true
						}
					},
					yaxis: {
						tickLength: 0,
						ticks: ticks
					},
					xaxis: {
						show: true,
						tickSize: (max > 15) ? Math.round(max / 15) : max,
						tickFormatter: function formatter(val, axis) {
							if (val === 0) {
								return val + ' hours(s)';
							} else {
								return val;
							}
						}
					},
					grid: {
						borderColor: 'CCCCCC',
						borderWidth: 0,
						hoverable: true,
						clickable: true
					}
				};

				plot = $.plot('.charts .tasks-bar', [mapped], options);
			} else {
				plot.resize();
				plot.setupGrid();
				plot.setData([mapped]);
				plot.draw();
			}
		};
{'fraction_non_alphanumeric': 0.17621464829586658, 'fraction_numerical': 0.01305293691080493, 'mean_word_length': 2.06973293768546, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6936646', 'n_tokens_mistral': 1975, 'n_tokens_neox': 1423, 'n_words': 314}