Permalink
Browse files

monitor: Don't add a newline before the first word

  • Loading branch information...
1 parent 0d154b6 commit 2bbddfa24072a67f48189140a496dbc87f6fd367 @dustin dustin committed Dec 23, 2013
Showing with 3 additions and 1 deletion.
  1. +3 −1 monitor/monitor.js
View
@@ -384,6 +384,7 @@ function wrap(text) {
var text = d3.select(this),
words = text.text().split(/\s+/).reverse(),
word,
+ wordsProcessed = 0,
line = [],
lineNumber = 0,
lineHeight = 1.1, // ems
@@ -394,12 +395,13 @@ function wrap(text) {
while (word = words.pop()) {
line.push(word);
tspan.text(line.join(" "));
- if (tspan.node().getComputedTextLength() > width) {
+ if (wordsProcessed > 0 && tspan.node().getComputedTextLength() > width) {
line.pop();
tspan.text(line.join(" "));
line = [word];
tspan = text.append("tspan").attr("x", 0).attr("y", y).attr("dy", ++lineNumber * lineHeight + dy + "em").text(word);
}
+ wordsProcessed++;
}
});
}

0 comments on commit 2bbddfa

Please sign in to comment.