<commit_before>/*!
 * OpenSpending BubbleChart 0.8
 *
 * Copyright (c) 2011 <NAME> (http://driven-by-data.net)
 * Licensed under the MIT license
 */
/*jshint undef: true, browser:true, jquery: true, devel: true */
/*global Raphael, TWEEN, vis4, vis4color */

var OpenSpending = OpenSpending ? OpenSpending : {}; 


OpenSpending.BubbleChart = function(config, onHover, onUnHover) {
	
	var me = this;
	
	me.$container = $(config.container);	
	
	me.config = config;
	
	/*
	 * this function is called when the user hovers a bubble
	 */
	//me.onHover = onHover;
	
	//me.onUnHover = onUnHover;
	me.tooltip = config.tooltipCallback;
	
	/*
	 * stylesheet JSON that contains colors and icons for the bubbles
	 */
	me.style = config.bubbleStyles;
	
	me.ns = OpenSpending.BubbleChart;
	
	me.nodesById = {};
	
	me.displayObjects = [];
	
	me.bubbleScale = 1;
	
	me.globRotation = 0;
	
	me.currentYear = config.initYear;
	
	me.currentCenter = undefined;
	
	me.currentTransition = undefined;
	
	/*
	 * @public loadData
	 * @deprecated!
	 */
	me.loadData = function(url) {
		$.ajax({
			url: url,
			dataType: 'json',
			success: this.setData.bind(this)
		});
	};
	
	/*
	 * is either called directly or by $.ajax when data json file is loaded
	 */
	me.setData = function(data) {
		var me = this;
		me.initData(data);
		me.initPaper();
		me.initBubbles();
		me.initTween();
		//me.navigateTo(me.treeRoot);
		me.initHistory();
		
		//this.quickPrototype(data);
	};
	
	/*
	 * initializes the data tree, adds links to parent node for easier traversal etc
	 */
	me.initData = function(root) {
		var me = this;
		me.traverse(root, 0);
		me.treeRoot = root;
	};
	
	/*
	 * used for recursive tree traversal
	 */
	me.traverse = function(node, index) {
		var c, child, pc, me = this;
		// set node color
		
		if (me.style.hasOwnProperty(node.id)) {
			node.color = me.style[node.id].color;	
		} else if (node.hasOwnProperty('color') && node.color !== undefined) {
			// use color given in data
			vis4.log('use data color', node.color);
		} else {
			// use color from parent node if no other match available
			if (node.level > 0) node.color = node.parent.color;
			else node.color = '#999999';
		}
		vis4.log(node.id, node.color, node);
		// lighten up the color if there are no children
		if (node.children.length < 1) {
			vis4.log(node.color);
			node.color = vis4color.fromHex(node.color).saturation('*.86').x;
		}
		
		if (node.level > 0) {
			pc = node.parent.children;
			if (pc.length > 1) {	
				node.left = pc[(index-1+pc.length) % pc.length];
				node.right = pc[(Number(index)+1) % pc.length];
				if (node.right == node.left) node.right = undefined;
			}
		}
		<commit_msg>storing formatted amount for each node<commit_after>/*!
 * OpenSpending BubbleChart 0.8
 *
 * Copyright (c) 2011 <NAME> (http://driven-by-data.net)
 * Licensed under the MIT license
 */
/*jshint undef: true, browser:true, jquery: true, devel: true */
/*global Raphael, TWEEN, vis4, vis4color */

var OpenSpending = OpenSpending ? OpenSpending : {}; 


OpenSpending.BubbleChart = function(config, onHover, onUnHover) {
	
	var me = this;
	
	me.$container = $(config.container);	
	
	me.config = config;
	
	/*
	 * this function is called when the user hovers a bubble
	 */
	//me.onHover = onHover;
	
	//me.onUnHover = onUnHover;
	me.tooltip = config.tooltipCallback;
	
	/*
	 * stylesheet JSON that contains colors and icons for the bubbles
	 */
	me.style = config.bubbleStyles;
	
	me.ns = OpenSpending.BubbleChart;
	
	me.nodesById = {};
	
	me.displayObjects = [];
	
	me.bubbleScale = 1;
	
	me.globRotation = 0;
	
	me.currentYear = config.initYear;
	
	me.currentCenter = undefined;
	
	me.currentTransition = undefined;
	
	/*
	 * @public loadData
	 * @deprecated!
	 */
	me.loadData = function(url) {
		$.ajax({
			url: url,
			dataType: 'json',
			success: this.setData.bind(this)
		});
	};
	
	/*
	 * is either called directly or by $.ajax when data json file is loaded
	 */
	me.setData = function(data) {
		var me = this;
		me.initData(data);
		me.initPaper();
		me.initBubbles();
		me.initTween();
		//me.navigateTo(me.treeRoot);
		me.initHistory();
		
		//this.quickPrototype(data);
	};
	
	/*
	 * initializes the data tree, adds links to parent node for easier traversal etc
	 */
	me.initData = function(root) {
		var me = this;
		me.traverse(root, 0);
		me.treeRoot = root;
	};
	
	/*
	 * used for recursive tree traversal
	 */
	me.traverse = function(node, index) {
		var c, child, pc, me = this;
		// set node color
		
		node.famount = me.ns.Utils.formatNumber(node.amount);
		
		if (me.style.hasOwnProperty(node.id)) {
			node.color = me.style[node.id].color;	
		} else if (node.hasOwnProperty('color') && node.color !== undefined) {
			// use color given in data
			vis4.log('use data color', node.color);
		} else {
			// use color from parent node if no other match available
			if (node.level > 0) node.color = node.parent.color;
			else node.color = '#999999';
		}
		vis4.log(node.id, node.color, node);
		// lighten up the color if there are no children
		if (node.children.length < 1) {
			vis4.log(node.color);
			node.color = vis4color.fromHex(node.color).saturation('*.86').x;
		}
		
		if (node.level > 0) {
			pc = node.parent.children;
			if (pc.length > 1) {	
				node.left = pc[(index-1+pc.length) % pc.length];
				node.right = pc[(Number(index)+1) % pc.length];
				if (node.right == node.left) node.right = undefined;
			}
		}
		
{'fraction_non_alphanumeric': 0.14885355029585798, 'fraction_numerical': 0.010724852071005916, 'mean_word_length': 2.9859985261606483, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '508516', 'n_tokens_mistral': 2162, 'n_tokens_neox': 1871, 'n_words': 475}