<commit_before>(function($){

///////
// TEST
this.TestChart= function(canvas) { 
var obj = {};   
obj.canvas = canvas;
obj.drawTestChart = function(ss) {
	console.log (ss);
	}
return obj;
}



//Modified from http://jsfiddle.net/datashaman/rBfy5/show
//////////////////////////////////////////
// Horizonal Stacked Bar Chart
this.HorizontalStackedBarChart= function(canvas) { 
	var obj = {};   
	obj.canvas = canvas;
	//Example
	//var dataset   = [{"data": [{"month": "Aug","count": 123}, {"month": "Sep","count": 234}, {"month": "Oct","count": 345}],"name": "Series #4"}, 
	//                 {"data": [{"month": "Aug","count": 235}, {"month": "Sep","count": 267}, {"month": "Oct","count": 573}],"name": "Series #5"}]
	obj.drawHorizontalStackedBarChart = function(ss) {
		$("#activerepositories").empty();    
		var margins = {
			    top: 12,
			    left: 100,  //Handle long repo names!
			    right: 24,
			    bottom: 24,
			    fudge: 274
			},
			legendPanel = {
			    width: 180
			},
			width = 700 - margins.left - margins.right - legendPanel.width,
			    height = 500 - margins.top - margins.bottom - margins.fudge,
			    dataset = JSON.parse(ss),
			    series = dataset.map(function (d) {
			    	//console.log ("d.name" , d.name);
			        return d.name;
			    }),
			    dataset = dataset.map(function (d) {
			        return d.data.map(function (o, i) {
			            // Structure it so that your numeric
			            // axis (the stacked amount) is y
			            //console.log(o.count, o.month);
			        	return {
			                y: o.count,
			                x: o.reponame,
			                z: o.month
			            };
			        });
			    }),
			    stack = d3.layout.stack();

			stack(dataset);

			var dataset = dataset.map(function (group) {
			    return group.map(function (d) {
			        // Invert the x and y values, and y0 becomes x0
			    	//console.log("inverting ...", d.x,d.y,d.y0);
			        return {
			            x: d.y,
			            y: d.x,
			            z: d.z,
			            x0: d.y0
			        };
			    });
			}),
                svg = d3.select($("#activerepositories")[0])
                .append("svg")
			    .attr('width', width + margins.left + margins.right + legendPanel.width)
			        .attr('height', height + margins.top + margins.bottom)
			        .append('g')
			        .attr('transform', 'translate(' + margins.left + ',' + margins.top + ')'),
			    xMax = d3.max(dataset, function (group) {
			        return d3.max(group, function (d) {
			        	 //Convert to int
			        	 return parseInt(d.x) + parseInt(d.x0);
			        });
			    }),
			    xScale = d3.scale.linear()
			        .domain([0, xMax])
			        .range([0, width]),
			    months = dataset[0].map(function (d) { 
			    	return d.y;
			    }),
			    //_ = console.log(months),
			    
			    yScale = d3.scale.ordinal()
			        .domain(months)
			        .rangeRoundBands([0, height], .1),
			        
			    xAxis = d3.svg.axis()
			        .scale(xScale)
			        .orient('bottom'),
			        
			    //TODO: Add link    
			    yAxis = d3.svg.axis()
			        .scale(yScale)
			        .orient('left'),
			    
			    colours = d3.scale.category10(),
			    groups = svg.selectAll('g')
			        .data(dataset)
			        .enter()
			        .append('g')
			        .style('fill', function (d, i) {
			        return colours(i);
			    }),
			    rects = groups.selectAll('rect')
			        .data(function (d) {
			        return d;
			    })
			        .enter()
			        .append('rect')
			        .attr('x', function (d) {
			        return xScale(d.x0);
			    })
			        .attr('y', function (d, i) {
			        return yScale(d.y);
			    })
			        .attr('height', function (d) {
			        return yScale.rangeBand();
			    })
			        .attr('width', function (d) {
			        return xScale(d.x);
			    })
			        .on('mouseover', function (d) {
			        var xPos = parseFloat(d3.select(this).attr('x')) / 2 + width / 2;
			        var yPos = parseFloat(d3.select(this).attr('y')) + yScale.rangeBand() / 2;

			        d3.select('#tooltip')
			            .style('left', xPos + 'px')
			            .style('top', yPos + 'px')
			            .select('#value')
			            .text(d.x);
                    //TODO: Fix tooltip
			        d3.select('#tooltip').classed('hidden', false);
			    })
			        .on('mouseout', function () {
			        d3.select('#tooltip').classed('hidden', true);
			    })

			    svg.append('g')
			        .attr('class', 'axis')
			        .attr('transform', 'translate(0,' + height + ')')
			        .call(xAxis);

			svg.append('g')
			    .attr('class', 'axis')
			    .call(yAxis);

			svg.append('rect')
			    .attr('fill', 'yellow')
			    .attr('width', 160)
			    .attr('height', 30 * dataset.length)
			    .attr('x', width + margins.left)
			    .attr('y', 0);<commit_msg>change bg color for legend<commit_after>(function($){

///////
// TEST
this.TestChart= function(canvas) { 
var obj = {};   
obj.canvas = canvas;
obj.drawTestChart = function(ss) {
	console.log (ss);
	}
return obj;
}



//Modified from http://jsfiddle.net/datashaman/rBfy5/show
//////////////////////////////////////////
// Horizonal Stacked Bar Chart
this.HorizontalStackedBarChart= function(canvas) { 
	var obj = {};   
	obj.canvas = canvas;
	//Example
	//var dataset   = [{"data": [{"month": "Aug","count": 123}, {"month": "Sep","count": 234}, {"month": "Oct","count": 345}],"name": "Series #4"}, 
	//                 {"data": [{"month": "Aug","count": 235}, {"month": "Sep","count": 267}, {"month": "Oct","count": 573}],"name": "Series #5"}]
	obj.drawHorizontalStackedBarChart = function(ss) {
		$("#activerepositories").empty();    
		var margins = {
			    top: 12,
			    left: 100,  //Handle long repo names!
			    right: 24,
			    bottom: 24,
			    fudge: 274
			},
			legendPanel = {
			    width: 180
			},
			width = 700 - margins.left - margins.right - legendPanel.width,
			    height = 500 - margins.top - margins.bottom - margins.fudge,
			    dataset = JSON.parse(ss),
			    series = dataset.map(function (d) {
			    	//console.log ("d.name" , d.name);
			        return d.name;
			    }),
			    dataset = dataset.map(function (d) {
			        return d.data.map(function (o, i) {
			            // Structure it so that your numeric
			            // axis (the stacked amount) is y
			            //console.log(o.count, o.month);
			        	return {
			                y: o.count,
			                x: o.reponame,
			                z: o.month
			            };
			        });
			    }),
			    stack = d3.layout.stack();

			stack(dataset);

			var dataset = dataset.map(function (group) {
			    return group.map(function (d) {
			        // Invert the x and y values, and y0 becomes x0
			    	//console.log("inverting ...", d.x,d.y,d.y0);
			        return {
			            x: d.y,
			            y: d.x,
			            z: d.z,
			            x0: d.y0
			        };
			    });
			}),
                svg = d3.select($("#activerepositories")[0])
                .append("svg")
			    .attr('width', width + margins.left + margins.right + legendPanel.width)
			        .attr('height', height + margins.top + margins.bottom)
			        .append('g')
			        .attr('transform', 'translate(' + margins.left + ',' + margins.top + ')'),
			    xMax = d3.max(dataset, function (group) {
			        return d3.max(group, function (d) {
			        	 //Convert to int
			        	 return parseInt(d.x) + parseInt(d.x0);
			        });
			    }),
			    xScale = d3.scale.linear()
			        .domain([0, xMax])
			        .range([0, width]),
			    months = dataset[0].map(function (d) { 
			    	return d.y;
			    }),
			    //_ = console.log(months),
			    
			    yScale = d3.scale.ordinal()
			        .domain(months)
			        .rangeRoundBands([0, height], .1),
			        
			    xAxis = d3.svg.axis()
			        .scale(xScale)
			        .orient('bottom'),
			        
			    //TODO: Add link    
			    yAxis = d3.svg.axis()
			        .scale(yScale)
			        .orient('left'),
			    
			    colours = d3.scale.category10(),
			    groups = svg.selectAll('g')
			        .data(dataset)
			        .enter()
			        .append('g')
			        .style('fill', function (d, i) {
			        return colours(i);
			    }),
			    rects = groups.selectAll('rect')
			        .data(function (d) {
			        return d;
			    })
			        .enter()
			        .append('rect')
			        .attr('x', function (d) {
			        return xScale(d.x0);
			    })
			        .attr('y', function (d, i) {
			        return yScale(d.y);
			    })
			        .attr('height', function (d) {
			        return yScale.rangeBand();
			    })
			        .attr('width', function (d) {
			        return xScale(d.x);
			    })
			        .on('mouseover', function (d) {
			        var xPos = parseFloat(d3.select(this).attr('x')) / 2 + width / 2;
			        var yPos = parseFloat(d3.select(this).attr('y')) + yScale.rangeBand() / 2;

			        d3.select('#tooltip')
			            .style('left', xPos + 'px')
			            .style('top', yPos + 'px')
			            .select('#value')
			            .text(d.x);
                    //TODO: Fix tooltip
			        d3.select('#tooltip').classed('hidden', false);
			    })
			        .on('mouseout', function () {
			        d3.select('#tooltip').classed('hidden', true);
			    })

			    svg.append('g')
			        .attr('class', 'axis')
			        .attr('transform', 'translate(0,' + height + ')')
			        .call(xAxis);

			svg.append('g')
			    .attr('class', 'axis')
			    .call(yAxis);

			svg.append('rect')
			    .attr('fill', 'white')
			    .attr('width', 160)
			    .attr('height', 30 * dataset.length)
			    .attr('x', width + margins.left)
			    .attr('y', 0);
{'fraction_non_alphanumeric': 0.1834247410115783, 'fraction_numerical': 0.016453382084095063, 'mean_word_length': 1.5100688248789191, 'pattern_counts': {'":': 32, '<': 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': '2929143', 'n_tokens_mistral': 3918, 'n_tokens_neox': 3002, 'n_words': 629}