changeset 1429:864e4daef963 beta

improved rendering of dag (they are not trimmed anymore when number of heads exceeds 5)
author Marcin Kuzminski <marcin@python-works.com>
date Sat, 16 Jul 2011 12:33:40 +0200
parents e5467730682b
children 9d19456c4f65
files rhodecode/public/css/style.css rhodecode/public/js/graph.js rhodecode/templates/changelog/changelog.html
diffstat 3 files changed, 19 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/public/css/style.css	Sat Jul 16 12:02:14 2011 +0200
+++ b/rhodecode/public/css/style.css	Sat Jul 16 12:33:40 2011 +0200
@@ -1736,15 +1736,14 @@
 }
 
 #graph_nodes {
-width:160px;
 float:left;
-margin-left:-50px;
 margin-top:5px;
 }
 
 #graph_content {
 width:800px;
 float:left;
+
 }
 
 #graph_content .container_header {
--- a/rhodecode/public/js/graph.js	Sat Jul 16 12:02:14 2011 +0200
+++ b/rhodecode/public/js/graph.js	Sat Jul 16 12:33:40 2011 +0200
@@ -58,10 +58,10 @@
 		this.ctx.fillStyle = s;
 	}
 
-	this.render = function(data) {
+	this.render = function(data,pad) {
 		var idx = 1;
 		var rela = document.getElementById('graph');
-		var pad = 160;
+		var pad = pad;
 		var scale = 22;
 		
 		for (var i in data) {
--- a/rhodecode/templates/changelog/changelog.html	Sat Jul 16 12:02:14 2011 +0200
+++ b/rhodecode/templates/changelog/changelog.html	Sat Jul 16 12:33:40 2011 +0200
@@ -139,21 +139,31 @@
                         }
                     });					
 					
-					function set_canvas() {
+					function set_canvas(heads) {
 						var c = document.getElementById('graph_nodes');
 						var t = document.getElementById('graph_content');
 						canvas = document.getElementById('graph_canvas');
 						var div_h = t.clientHeight;
 						c.style.height=div_h+'px';
 						canvas.setAttribute('height',div_h);
-						canvas.setAttribute('width',160);
+						c.style.height=max_w+'px';
+						canvas.setAttribute('width',max_w);
 					};
-					set_canvas();
+					var heads = 1;
+					var max_heads = 0;
 					var jsdata = ${c.jsdata|n};
+					
+					for( var i=0;i<jsdata.length;i++){
+					    var m = Math.max.apply(Math, jsdata[i][1]);
+					    if (m>max_heads){
+					        max_heads = m;
+					    }
+					}
+					var max_w = Math.max(100,max_heads*25);
+					set_canvas(max_w);
+					
 					var r = new BranchRenderer();
-					r.render(jsdata);
-					
-
+					r.render(jsdata,max_w);
 					
 				});
 			</script>