Changeset - 1ab6b1cb849a
[Not reviewed]
beta
0 1 0
Aras Pranckevicius - 13 years ago 2012-10-15 15:01:29
aras@unity3d.com
graph: replaced some super complicated looking math with something that tries to make sense
1 file changed with 10 insertions and 14 deletions:
0 comments (0 inline, 0 general)
rhodecode/public/js/graph.js
Show inline comments
 
@@ -45,72 +45,68 @@ function BranchRenderer() {
 
		blue = Math.round(blue * 255);
 
		var s = 'rgb(' + red + ', ' + green + ', ' + blue + ')';
 
		this.ctx.strokeStyle = s;
 
		this.ctx.fillStyle = s;
 
	}
 

	
 
	this.render = function(data,width) {
 
	this.render = function(data,canvasWidth) {
 
		var idx = 1;
 
		var rela = document.getElementById('graph');
 
		var pad = width;
 
		var scale = 22;
 
		var box_size = Math.floor(scale/1.2);
 

	
 
		var box_size = 18;
 

	
 
		for (var i in data) {
 

	
 
			var row = document.getElementById("chg_"+idx);
 
			if (row == null)
 
				continue;
 
			var	next = document.getElementById("chg_"+(idx+1));
 
			var extra = 0;
 
			
 
			cur = data[i];
 
			nodeid = cur[0];
 
			node = cur[1];
 
			in_l = cur[2];
 

	
 
			var rowY = row.offsetTop + row.offsetHeight/2 - rela.offsetTop;
 
			var nextY = (next == null) ? rowY + row.offsetHeight/2 : next.offsetTop + next.offsetHeight/2 - rela.offsetTop;
 

	
 
			for (var j in in_l) {
 
				
 
				line = in_l[j];
 
				start = line[0];
 
				end = line[1];
 
				start = line[0] + 1;
 
				end = line[1] + 1;
 
				color = line[2];
 

	
 
				this.setColor(color, 0.0, 0.65);
 

	
 
				
 
				x = pad-(box_size * start - 1 + scale);
 
				x = canvasWidth - box_size * start;
 
				
 
				this.ctx.lineWidth=this.line_width;
 
				this.ctx.beginPath();
 
				this.ctx.moveTo(x, rowY);
 

	
 
				
 
				if (start == end)
 
				{
 
					x = pad-((1 + box_size * end) + scale-2);
 
					this.ctx.lineTo(x,nextY+extra,3);
 
				}
 
				else
 
				{
 
					var x2 = pad-((1 + box_size * end) + scale-2);
 
					var x2 = canvasWidth - box_size * end;
 
					var ymid = (rowY+nextY) / 2;
 
					this.ctx.bezierCurveTo (x,ymid,x2,ymid,x2,nextY);
 
				}
 
				this.ctx.stroke();
 
			}
 
			
 
			column = node[0]
 
			color = node[1]
 
			column = node[0] + 1;
 
			color = node[1];
 
			
 
			radius = this.dot_radius;
 

	
 
			x = pad-(Math.round(scale * column + radius) + 15 - (column*4));
 
			x = canvasWidth - box_size * column;
 
		
 
			this.ctx.beginPath();
 
			this.setColor(color, 0.25, 0.75);
 
			this.ctx.arc(x, rowY, radius, 0, Math.PI * 2, true);
 
			this.ctx.fill();
 
			
0 comments (0 inline, 0 general)