changeset 1873:cc5dc31859d4 beta

graph: make it handle different row heights while still doing dots in the middle of each row
author Aras Pranckevicius <aras@unity3d.com>
date Mon, 09 Jan 2012 09:16:43 +0200
parents 6300364efc35
children 303ef179f750
files rhodecode/public/js/graph.js
diffstat 1 files changed, 10 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/public/js/graph.js	Mon Jan 09 09:01:37 2012 +0200
+++ b/rhodecode/public/js/graph.js	Mon Jan 09 09:16:43 2012 +0200
@@ -67,7 +67,7 @@
 		for (var i in data) {
 			this.scale(scale);
 			var row = document.getElementById("chg_"+idx);
-			var	next = document.getElementById("chg_"+idx+1);
+			var	next = document.getElementById("chg_"+(idx+1));
 			var extra = 0;
 			
 			//skip this since i don't have DATE in my app
@@ -82,7 +82,10 @@
 			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];
@@ -100,26 +103,23 @@
 				
 				this.setColor(color, 0.0, 0.65);
 				
-				y = row.offsetTop-rela.offsetTop+row.offsetHeight/2;
 				x = pad-((this.cell[0] + this.box_size * start - 1) + this.bg_height-2);
 				
 				this.ctx.lineWidth=this.line_width;
 				this.ctx.beginPath();
-				this.ctx.moveTo(x, y);
+				this.ctx.moveTo(x, rowY);
 
 				
 				if (start == end)
 				{
 					x = pad-((1 + this.box_size * end) + this.bg_height-2);
-					y += row.offsetHeight;
-					this.ctx.lineTo(x,y+extra,3);
+					this.ctx.lineTo(x,nextY+extra,3);
 				}
 				else
 				{
 					var x2 = pad-((1 + this.box_size * end) + this.bg_height-2);
-					var y2 = y + row.offsetHeight;
-					var ymid = (y+y2) / 2;
-					this.ctx.bezierCurveTo (x,ymid,x2,ymid,x2,y2);
+					var ymid = (rowY+nextY) / 2;
+					this.ctx.bezierCurveTo (x,ymid,x2,ymid,x2,nextY);
 				}
 				this.ctx.stroke();
 			}
@@ -128,12 +128,11 @@
 			color = node[1]
 			
 			radius = this.dot_radius;
-			y = row.offsetTop-rela.offsetTop+row.offsetHeight/2;
 			x = pad-(Math.round(this.cell[0] * scale/2 * column + radius) + 15 - (column*4));
 		
 			this.ctx.beginPath();
 			this.setColor(color, 0.25, 0.75);
-			this.ctx.arc(x, y, radius, 0, Math.PI * 2, true);
+			this.ctx.arc(x, rowY, radius, 0, Math.PI * 2, true);
 			this.ctx.fill();
 			
 			idx++;