From 2191a0c2461bb24a566d04253041eff108a5166a Mon Sep 17 00:00:00 2001 From: Gregory Eremin Date: Sun, 8 Mar 2015 22:44:48 +0700 Subject: [PATCH] Fix label underlay positioning --- app/scripts/charts.jsx | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/app/scripts/charts.jsx b/app/scripts/charts.jsx index 3e6330b..8ae6347 100644 --- a/app/scripts/charts.jsx +++ b/app/scripts/charts.jsx @@ -1,4 +1,5 @@ -var Router = ReactRouter; +var SVGNS = "http://www.w3.org/2000/svg", + Router = ReactRouter; var BarChart = React.createClass({ barHeight: 40, @@ -60,11 +61,12 @@ var Bar = React.createClass({ render: function() { var p = this.props.point w = this.props.width*500, - label = p.item + ": " + p.commits, - lw = label.length*10 + 5, - tx = 10; - if (lw > w) { - tx = w + tx; + label = p.item + ': ' + p.commits, + labelm = 10, // Margin + labelw = label.length*9 + 2*labelm, // Width + textx = labelm; + if (labelw + 2*labelm > w) { + textx = w + textx; } return ( @@ -72,8 +74,11 @@ var Bar = React.createClass({ width={this.props.width*500} height={this.props.height} x="0" y={this.props.y} rx="2" ry="2" /> - - {label} + + {label} ); }