<commit_before>;(function(factory){
	if (typeof define == 'function' && define.amd){
		define(['d3', 'jquery', 'd3-tip'], factory);
	} else {
		this.TimePlunk = factory(
			this.d3,
			this.jQuery
		);
	}
}).call(this, function(d3, $){
	/**
	 *
	 * @param {String|HTMLElement} element to bind to
	 * @param {Object} options
	 * @constructor
	 */
	function TimePlunk(element, options){
		this.options = $.extend({}, {
			// margins
			top: 0,
			bottom: 20,
			right: 0,
			left: 0,

			// base width/height
			width: 300,
			height: 90,

			interpolateMethod: 'linear',

			// xAxis
			maxTicks: 3,

			brushEvent: 'brushend',

			// date format
			dateFormat: '%d/%m/%y',

			// tooltip
			tooltipClass: 'd3-tip',
			tooltipsEnabled: true,
			tooltipFormat: function(d){
				return d.nice + ' <span style="color:red">' + d.y + '</span>';
			},

			onBrush: function(x, y){},

			// function that parses
			dataParser: null
		}, options);

		var o = this.options;

		// chart size
		this.width = o.width - o.left - o.right;
		this.height = o.height + o.bottom;

		this.svg = d3.select(element);
		this.svg.attr('width', this.width + o.left + o.right)
			.attr('height', this.height + o.top + o.bottom);


		// series scaling
		var x = this.x = d3.time.scale().range([0, this.width]);
		var y = this.y = d3.scale.linear().range([this.height, 0]);

		this._setxaxis();

		// brush for selection
		this.brush = d3.svg.brush().x(x).on(o.brushEvent, this.onBrush.bind(this));

		// plot area
		this.area = d3.svg.area().interpolate(o.interpolateMethod).x(function(d){
			return x(d.x);
		}).y0(this.height).y1(function(d){
			return y(d.y);
		});

		// tooltip
		d3.tip && this.options.tooltipsEnabled && this.setTooltip();
	}

	/**
	 * Internal onBrush event handler that exports selected range
	 * @returns {TimePlunk}
	 */
	TimePlunk.prototype.onBrush = function(){
		var data = this.brush.empty() ? this.x.domain() : this.brush.extent();
		this.options.onBrush.apply(this, data);

		return this;
	};

	/**
	 *
	 * @returns {TimePlunk}
	 */
	TimePlunk.prototype.resetSelection = function(){
		d3.select('.brush').call(this.brush.clear());

		return this;
	};

	TimePlunk.prototype._setxaxis = function(){
		// legend
		this.xAxis || (this.xAxis = d3.svg.axis().scale(this.x).ticks(this.options.maxTicks).orient('bottom').tickFormat(d3.time.format(this.options.dateFormat)));
	};

	/**
	 * Used to enable tooltip if available
	 * @returns {TimePlunk}
	 */
	TimePlunk.prototype.setTooltip = function(){
		this.tip = d3.tip()
			.attr('class', this.options.tooltipClass)
			.offset([-10, 0])
			.html(this.options.tooltipFormat);

		this.svg.append('defs').append('clipPath')
			.attr('id', 'clip')
			.append('rect')
			.attr('width', this.width)
			.attr('height', this.height)
			.call(this.tip);

		return this;
	};

	/**
	 * Used to set series data and parses/mods the array.
	 * @param {Array} data
	 * @returns {TimePlunk}
	 */
	TimePlunk.prototype.setData = function(data){
		var o = this.options;
		this.data = o.dataParser ? o.dataParser(data) : data;
		this.x.domain(d3.extent(this.data.map(function(item){
			return item.x;
		})));

		this.y.domain([0, d3.max(this.data.map(function(item){
			return item.y;<commit_msg>d3tip amd break<commit_after>;(function(factory){
	if (typeof define == 'function' && define.amd){
		define(['d3', 'jquery', 'd3-tip'], factory);
	} else {
		this.TimePlunk = factory(
			this.d3,
			this.jQuery
		);
	}
}).call(this, function(d3, $, d3tip){
	typeof d3tip === 'undefined' && (d3tip = d3.tip);
	/**
	 *
	 * @param {String|HTMLElement} element to bind to
	 * @param {Object} options
	 * @constructor
	 */
	function TimePlunk(element, options){
		this.options = $.extend({}, {
			// margins
			top: 0,
			bottom: 20,
			right: 0,
			left: 0,

			// base width/height
			width: 300,
			height: 90,

			interpolateMethod: 'linear',

			// xAxis
			maxTicks: 3,

			brushEvent: 'brushend',

			// date format
			dateFormat: '%d/%m/%y',

			// tooltip
			tooltipClass: 'd3-tip',
			tooltipsEnabled: true,
			tooltipFormat: function(d){
				return d.nice + ' <span style="color:red">' + d.y + '</span>';
			},

			onBrush: function(x, y){},

			// function that parses
			dataParser: null
		}, options);

		var o = this.options;

		// chart size
		this.width = o.width - o.left - o.right;
		this.height = o.height + o.bottom;

		this.svg = d3.select(element);
		this.svg.attr('width', this.width + o.left + o.right)
			.attr('height', this.height + o.top + o.bottom);


		// series scaling
		var x = this.x = d3.time.scale().range([0, this.width]);
		var y = this.y = d3.scale.linear().range([this.height, 0]);

		this._setxaxis();

		// brush for selection
		this.brush = d3.svg.brush().x(x).on(o.brushEvent, this.onBrush.bind(this));

		// plot area
		this.area = d3.svg.area().interpolate(o.interpolateMethod).x(function(d){
			return x(d.x);
		}).y0(this.height).y1(function(d){
			return y(d.y);
		});

		// tooltip
		d3tip && this.options.tooltipsEnabled && this.setTooltip();
	}

	/**
	 * Internal onBrush event handler that exports selected range
	 * @returns {TimePlunk}
	 */
	TimePlunk.prototype.onBrush = function(){
		var data = this.brush.empty() ? this.x.domain() : this.brush.extent();
		this.options.onBrush.apply(this, data);

		return this;
	};

	/**
	 *
	 * @returns {TimePlunk}
	 */
	TimePlunk.prototype.resetSelection = function(){
		d3.select('.brush').call(this.brush.clear());

		return this;
	};

	TimePlunk.prototype._setxaxis = function(){
		// legend
		this.xAxis || (this.xAxis = d3.svg.axis().scale(this.x).ticks(this.options.maxTicks).orient('bottom').tickFormat(d3.time.format(this.options.dateFormat)));
	};

	/**
	 * Used to enable tooltip if available
	 * @returns {TimePlunk}
	 */
	TimePlunk.prototype.setTooltip = function(){
		this.tip = d3tip()
			.attr('class', this.options.tooltipClass)
			.offset([-10, 0])
			.html(this.options.tooltipFormat);

		this.svg.append('defs').append('clipPath')
			.attr('id', 'clip')
			.append('rect')
			.attr('width', this.width)
			.attr('height', this.height)
			.call(this.tip);

		return this;
	};

	/**
	 * Used to set series data and parses/mods the array.
	 * @param {Array} data
	 * @returns {TimePlunk}
	 */
	TimePlunk.prototype.setData = function(data){
		var o = this.options;
		this.data = o.dataParser ? o.dataParser(data) : data;
		this.x.domain(d3.extent(this.data.map(function(item){
			return item.x;
		})));

		this.y.domain([0, d3.max(this.data.map(function(item){
			return item.y;
{'fraction_non_alphanumeric': 0.1878648233486943, 'fraction_numerical': 0.011827956989247311, 'mean_word_length': 3.1844473007712084, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2701181', 'n_tokens_mistral': 2732, 'n_tokens_neox': 2358, 'n_words': 459}