<commit_before>'use strict';

var _  = require('lodash');
var d3 = require('d3');

var palette = require('colors');

var defaults = {
	hoverRadius : 5,
	onClick     : _.noop,
	onMouseOver : _.noop,
	onMouseOut  : _.noop,
	radius      : 3,
	x           : _.property('x'),
	xFormat     : d3.format('n'),
	xScale      : d3.scale.linear,
	y           : _.property('y'),
	yFormat     : d3.format('n'),
	yScale      : d3.scale.linear,

	margin : {
		top    : 0,
		right  : 0,
		bottom : 24,
		left   : 24
	}
}

function ScatterPlot () {}

_.extend(ScatterPlot.prototype, {
	defaults : defaults,

	update : function (data, options) {
		options    = _.assign(this._options, options);
		var margin = options.margin;

		var svg = this._svg;
		var w   = this._width - margin.left - margin.right;
		var h   = this._height - margin.top - margin.bottom;

		var domain = _.isFunction(options.domain) ?
			options.domain(data) :
			d3.extent(_.map(data, options.x));

		var xScale = options.xScale()
			.domain(domain)
			.range([0, w])
			.nice();

		var x = function (d) { return xScale(options.x(d)); }

		var range = _.isFunction(options.range) ?
			options.range(data) :
			d3.extent(_.map(data, options.y));

		var yScale = options.yScale()
			.domain(range)
			.range([h, 0])
			.nice();

		var y = function (d) { return yScale(options.y(d)); };

		var point = svg.select('.data').selectAll('.point').data(data, function (d, i) {
			return d.hasOwnProperty('id') ? d.id : i;
		});

		var attrs = {
			'cx'   : x,
			'cy'   : y,
			'r'    : options.radius
		};

		point.enter()
			.append('circle')
			.attr('class', 'point')
			.attr(attrs);

		point
			.on('click', options.onClick)
			.on('mouseover', options.onMouseOver)
			.on('mouseout', options.onMouseOut);

		point.transition()
			.duration(300)
			.style('fill', palette[0])
			.attr(attrs);

		point.exit()
			.transition()
			.duration(300)
			.attr('r', 0)
			.remove();

		var xAxis = d3.svg.axis()
			.scale(xScale)
			.tickFormat(options.xFormat)
			.tickSize(-h)<commit_msg>Restore the hover animation to scatter plots<commit_after>'use strict';

var _  = require('lodash');
var d3 = require('d3');

var palette = require('colors');

var defaults = {
	hoverRadius : 5,
	onClick     : _.noop,
	onMouseOver : _.noop,
	onMouseOut  : _.noop,
	radius      : 3,
	x           : _.property('x'),
	xFormat     : d3.format('n'),
	xScale      : d3.scale.linear,
	y           : _.property('y'),
	yFormat     : d3.format('n'),
	yScale      : d3.scale.linear,

	margin : {
		top    : 0,
		right  : 0,
		bottom : 24,
		left   : 24
	}
}

function ScatterPlot () {}

_.extend(ScatterPlot.prototype, {
	defaults : defaults,

	update : function (data, options) {
		options    = _.assign(this._options, options);
		var margin = options.margin;

		var svg = this._svg;
		var w   = this._width - margin.left - margin.right;
		var h   = this._height - margin.top - margin.bottom;

		var domain = _.isFunction(options.domain) ?
			options.domain(data) :
			d3.extent(_.map(data, options.x));

		var xScale = options.xScale()
			.domain(domain)
			.range([0, w])
			.nice();

		var x = function (d) { return xScale(options.x(d)); }

		var range = _.isFunction(options.range) ?
			options.range(data) :
			d3.extent(_.map(data, options.y));

		var yScale = options.yScale()
			.domain(range)
			.range([h, 0])
			.nice();

		var y = function (d) { return yScale(options.y(d)); };

		var point = svg.select('.data').selectAll('.point').data(data, function (d, i) {
			return d.hasOwnProperty('id') ? d.id : i;
		});

		var attrs = {
			'cx'   : x,
			'cy'   : y,
			'r'    : options.radius
		};

		point.enter()
			.append('circle')
			.attr('class', 'point')
			.attr(attrs);

		point
			.on('click', function (d, i) {
				options.onClick(d, i, this);
			})
			.on('mouseover', function (d, i) {
				d3.select(this)
					.transition()
					.duration(500)
					.ease('elastic')
					.attr('r', options.hoverRadius);

				options.onMouseOver(d, i, this);
			})
			.on('mouseout', function (d, i) {
				d3.select(this)
					.transition()
					.duration(500)
					.ease('elastic')
					.attr('r', options.radius);

				options.onMouseOut(d, i, this);
			});

		point.transition()
			.duration(300)
			.style('fill', palette[0])
			.attr(attrs);

		point.exit()
			.transition()
			.duration(300)
			.attr('r', 0)
			.remove();

		var xAxis = d3.svg.axis()
			.scale(xScale)
			.tickFormat(options.xFormat)
			.tickSize(-h)
{'fraction_non_alphanumeric': 0.18157303370786518, 'fraction_numerical': 0.013932584269662922, 'mean_word_length': 2.657354149548069, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2189804', 'n_tokens_mistral': 1949, 'n_tokens_neox': 1645, 'n_words': 344}