changeset 2923:1ab6b1cb849a beta

graph: replaced some super complicated looking math with something that tries to make sense
author Aras Pranckevicius <aras@unity3d.com>
date Mon, 15 Oct 2012 16:01:29 +0300
parents 1f3ae3690756
children fcbcef60be02
files rhodecode/public/js/graph.js
diffstat 1 files changed, 10 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/public/js/graph.js	Mon Oct 15 15:46:14 2012 +0300
+++ b/rhodecode/public/js/graph.js	Mon Oct 15 16:01:29 2012 +0300
@@ -48,12 +48,11 @@
 		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) {
 
@@ -64,7 +63,6 @@
 			var extra = 0;
 			
 			cur = data[i];
-			nodeid = cur[0];
 			node = cur[1];
 			in_l = cur[2];
 
@@ -74,40 +72,38 @@
 			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);