[ Launch: SVG resize to containe ] 5320723 by biovisualize
[ Launch: SVG resize to containe ] 5052807 by biovisualize
[ Launch Inlet ]
Gist #3200444
-
-
Save biovisualize/5320723 to your computer and use it in GitHub Desktop.
Word wrap with foreignObject
This file contains 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
{"description":" Word wrap with foreignObject","endpoint":"","display":"div","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"tab":"edit","display_percent":0.7,"hidepanel":true} |
This file contains 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
// Change the size here to see it wrap | |
var w = 300 | |
var h = 300; | |
var div = d3.select("#display") | |
.append('div') | |
.style({background: 'aliceblue', | |
width: w + 'px', | |
height: h + 'px' | |
}); | |
var svg = div.append("svg") | |
.attr({width: w, height: h}); | |
svg.append("foreignObject") | |
.attr({width: w, height: h}) | |
.append("xhtml:body") | |
.append("xhtml:div") | |
.style({width: w + 'px', | |
height: h + 'px', | |
"font-size": "20px", | |
"background-color": "white" | |
}) | |
.html("“I can't believe I've been passed over for Long John Silver,” said Mr. Molesley. The lawn introduced the doctor. A poor man made sport of Highclere Castle. “Well we could always start with Mrs Crawley and Lady Grantham,” informed Mrs. Levinson. “Not worse than a maid serving a duke,” argued Mr. Mason."); | |
svg.append('circle') | |
.attr({cx: w/2, | |
cy: h/2, | |
r: Math.min(w, h)/2, | |
fill: "none", | |
stroke: "dodgerblue" | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment