<commit_before>var d3gentree = d3gentree || {};

d3gentree.encode_as_img_and_link = function() {
	// Add some critical information
	svg = $("svg").attr({
		version: '1.1',
		xmlns: "http://www.w3.org/2000/svg",
		"xmlns:xlink": "http://www.w3.org/1999/xlink"
	});
	xmlHeader = '<?xml version="1.0" encoding="Latin1"?>';
    currentHTML= $("#svg").parent().html();
    d3gentree.inkskapeWorkaround();
	var b64 = btoa(xmlHeader + $("#svg").parent().html().replace(/’/g, "'").replace(/&nbsp;/g, " "));
	$("#svg").parent().html(currentHTML);
	// or use btoa if supported

	// Works in recent Webkit(Chrome)
	//$("body").append($("<img src='data:image/svg+xml;base64,\n"+b64+"' alt='file.svg'/>"));
	// Works in Firefox 3.6 and Webkit and possibly any browser which supports the data-uri
	$(".download").remove();
	$("body").append($("<div class='download'><a href-lang='image/svg+xml' href='data:image/svg+xml;base64,\n" + b64 + "' title='file.svg' download='file.svg'>Download as svg</a></div>"));
}
d3gentree.inkskapeWorkaround= function() {
    $("#svg textPath[text-anchor='middle']").parent().each(function (){
        this.setAttribute('dx',this.getAttribute('dx')*2);
    })
}
d3gentree.compute_canvas_size = function(sourceNb) {
	if (d3gentree.param.data[sourceNb].source.ancestors.length < d3gentree.param.asc.expandStart) {
		rMax = d3gentree.param.general.centerSize + d3gentree.param.general.radius * d3gentree.param.data[sourceNb].source.ancestors.length - d3gentree.param.general.padding / 2;
	} else {
		rMax = d3gentree.param.general.centerSize + d3gentree.param.general.radius * (d3gentree.param.asc.expandStart - 1) + d3gentree.param.general.radiusRadial * (d3gentree.param.data[sourceNb].source.ancestors.length - (d3gentree.param.asc.expandStart - 1)) - d3gentree.param.general.padding / 2;
	}
	d3gentree.w = 2 * rMax + 50;
	d3gentree.h = 2 * rMax + 50;
}
// Draw center element
d3gentree.draw_center = function(pers) {
	//add center text
	var centerText = d3gentree.vis.append("g") //
	.attr("class", "text") //
	.style("fill", "black");

	centerText.append("text") //
	.style("font-size", d3gentree.param.general.nameFontSize + "px") //
	.style("font-weight", "bold") //
	.attr("dy", -5).attr("text-anchor", "middle") //
	.text(pers.name.substring(0, Math.min((d3gentree.param.general.centerSize * 2 / 9) + 1, pers.name.length + 1)));

	centerText.append("text") //
	.attr("dy", 15).style("font-size", d3gentree.param.general.fnameFontSize + "px") //
	.attr("text-anchor", "middle") //
	.text(pers.fname.substring(0, Math.min((d3gentree.param.general.centerSize * 2 / 9) + 1, pers.fname.length + 1)));
}
d3gentree.drawAscendants = function(dataSource, sourceNb, sosa, inR_orig, startA_orig, endA_orig, orient) {
	generation = parseInt(sosa).toString(2).length - 1;
	branch = sosa - Math.pow(2, generation);
	if (generation > d3gentree.param.asc.expandStart) {
		var thisR = d3gentree.param.general.radiusRadial;
		var radialText = 1;
	} else {
		var thisR = d3gentree.param.general.radius;
		var radialText = 0;<commit_msg>Compute size also based on descendants<commit_after>var d3gentree = d3gentree || {};

d3gentree.encode_as_img_and_link = function() {
	// Add some critical information
	svg = $("svg").attr({
		version: '1.1',
		xmlns: "http://www.w3.org/2000/svg",
		"xmlns:xlink": "http://www.w3.org/1999/xlink"
	});
	xmlHeader = '<?xml version="1.0" encoding="Latin1"?>';
    currentHTML= $("#svg").parent().html();
    d3gentree.inkskapeWorkaround();
	var b64 = btoa(xmlHeader + $("#svg").parent().html().replace(/’/g, "'").replace(/&nbsp;/g, " "));
	$("#svg").parent().html(currentHTML);
	// or use btoa if supported

	// Works in recent Webkit(Chrome)
	//$("body").append($("<img src='data:image/svg+xml;base64,\n"+b64+"' alt='file.svg'/>"));
	// Works in Firefox 3.6 and Webkit and possibly any browser which supports the data-uri
	$(".download").remove();
	$("body").append($("<div class='download'><a href-lang='image/svg+xml' href='data:image/svg+xml;base64,\n" + b64 + "' title='file.svg' download='file.svg'>Download as svg</a></div>"));
}
d3gentree.inkskapeWorkaround= function() {
    $("#svg textPath[text-anchor='middle']").parent().each(function (){
        this.setAttribute('dx',this.getAttribute('dx')*2);
    })
}
d3gentree.compute_canvas_size = function(sourceNb) {
	if (d3gentree.param.data[sourceNb].source.ancestors.length < d3gentree.param.asc.expandStart) {
		rMax = d3gentree.param.general.centerSize + d3gentree.param.general.radius * d3gentree.param.data[sourceNb].source.ancestors.length - d3gentree.param.general.padding / 2;
	} else {
		rMax = d3gentree.param.general.centerSize + d3gentree.param.general.radius * (d3gentree.param.asc.expandStart - 1) + d3gentree.param.general.radiusRadial * (d3gentree.param.data[sourceNb].source.ancestors.length - (d3gentree.param.asc.expandStart - 1)) - d3gentree.param.general.padding / 2;
	}
    function depthRec(indivData,curR,generation){
        var maxR=curR;
        for (var m = 0; m < indivData.marriages.length; ++m) {
            var outR_s = curR + (generation > d3gentree.param.desc.expandStart ? d3gentree.param.general.radiusRadial : d3gentree.param.general.radius) * (generation > d3gentree.param.desc.expandStart ? d3gentree.param.desc.spouseRadiusRatio : 1);
            maxR=Math.max(maxR,outR_s);
            for (var c = 0; c < indivData.marriages[m].children.length; ++c) {
                var inR = outR_s + d3gentree.param.desc.generationSpacing;
                var outR = inR + (generation + 1 > d3gentree.param.desc.expandStart ? d3gentree.param.general.radiusRadial : d3gentree.param.general.radius);
                var R=depthRec(indivData.marriages[m].children[c],outR,generation+2);
                maxR=Math.max(maxR,R);
            }
        }
        return maxR;
    }
	rMax=Math.max(rMax,depthRec(d3gentree.param.data[sourceNb].source.source,d3gentree.param.general.centerSize,0));
	d3gentree.w = 2 * rMax + 50;
	d3gentree.h = 2 * rMax + 50;
}
// Draw center element
d3gentree.draw_center = function(pers) {
	//add center text
	var centerText = d3gentree.vis.append("g") //
	.attr("class", "text") //
	.style("fill", "black");

	centerText.append("text") //
	.style("font-size", d3gentree.param.general.nameFontSize + "px") //
	.style("font-weight", "bold") //
	.attr("dy", -5).attr("text-anchor", "middle") //
	.text(pers.name.substring(0, Math.min((d3gentree.param.general.centerSize * 2 / 9) + 1, pers.name.length + 1)));

	centerText.append("text") //
	.attr("dy", 15).style("font-size", d3gentree.param.general.fnameFontSize + "px") //
	.attr("text-anchor", "middle") //
	.text(pers.fname.substring(0, Math.min((d3gentree.param.general.centerSize * 2 / 9) + 1, pers.fname.length + 1)));
}
d3gentree.drawAscendants = function(dataSource, sourceNb, sosa, inR_orig, startA_orig, endA_orig, orient) {
	generation = parseInt(sosa).toString(2).length - 1;
	branch = sosa - Math.pow(2, generation);
	if (generation > d3gentree.param.asc.expandStart) {
		var thisR = d3gentree.param.general.radiusRadial;
		var radialText = 1;
	} else {
		var thisR = d3gentree.param.general.radius;
		var radialText = 0;
{'fraction_non_alphanumeric': 0.1910836954997897, 'fraction_numerical': 0.02677695219402776, 'mean_word_length': 4.188363636363636, 'pattern_counts': {'":': 2, '<': 19, '<?xml version=': 2, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 16}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5160322', 'n_tokens_mistral': 2729, 'n_tokens_neox': 2615, 'n_words': 408}