# HG changeset patch # User Mads Kiilerich # Date 2015-05-13 01:16:48 # Node ID 1cc64983363a5e669bf146504b0fd3103a4212a7 # Parent a9d2e29585146ae77836c846ad2eacacdbd16f26 graph: fix graph drawing if there is less than one pixel available per branch The branch width would be rounded down and the graph would be 0 pixels wide and thus even more unreadable than it should have been. diff --git a/kallithea/public/js/graph.js b/kallithea/public/js/graph.js --- a/kallithea/public/js/graph.js +++ b/kallithea/public/js/graph.js @@ -89,7 +89,7 @@ function BranchRenderer(canvas_id, conte } var edge_pad = this.dot_radius + 2; - var box_size = Math.min(18, Math.floor((canvasWidth - edge_pad*2)/(lineCount))); + var box_size = Math.min(18, (canvasWidth - edge_pad * 2) / lineCount); var base_x = canvasWidth - edge_pad; for (var i=0; i < data.length; ++i) { @@ -115,7 +115,7 @@ function BranchRenderer(canvas_id, conte end = line[1]; color = line[2]; - x = base_x - box_size * start; + x = Math.floor(base_x - box_size * start); // figure out if this is a dead-end; // we want to fade away this line @@ -165,7 +165,7 @@ function BranchRenderer(canvas_id, conte } else { - var x2 = base_x - box_size * end; + var x2 = Math.floor(base_x - box_size * end); var ymid = (rowY+nextY) / 2; this.ctx.bezierCurveTo (x,ymid,x2,ymid,x2,nextY); } @@ -175,7 +175,7 @@ function BranchRenderer(canvas_id, conte column = node[0]; color = node[1]; - x = base_x - box_size * column; + x = Math.floor(base_x - box_size * column); this.setColor(color, 0.25, 0.75); if (closing)