Created
July 10, 2012 23:53
-
-
Save roundrobin/3087025 to your computer and use it in GitHub Desktop.
just another inlet to tributary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var width = 677; | |
| var text = "Das ist einn schon lange text und der soll assdfsdf sdlfksdf bla bla bla der ist auch so coooooll auch noch viel langer werden verstanden???"; | |
| g.append("text").text(text).attr("y",200).attr("x",30) | |
| g.append("rect").attr("width",width).attr("height",200).attr("y",200).attr("x",30).attr("fill","red") | |
| var mothership = g.append("text").attr("height",200).attr("y",354).attr("x",30).attr("fill","green") | |
| var textArray = text.split(" ") | |
| var tspan = mothership.append("tspan") | |
| var i = 0 | |
| for(i in textArray){ | |
| var textLength = mothership.node().getComputedTextLength() | |
| if(textLength >= width){ | |
| i++; | |
| tspan = mothership.append("tspan").attr("dy",22) | |
| } | |
| tspan.text(tspan.text()+" "+textArray[i]) | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment