Skip to content

Instantly share code, notes, and snippets.

@roundrobin
Created July 4, 2012 00:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roundrobin/3044444 to your computer and use it in GitHub Desktop.
Save roundrobin/3044444 to your computer and use it in GitHub Desktop.
just another inlet to tributary
var width = 792
var height = 83
var font_size = 913
var x = 58
var y = 119
var rect = g.append("rect")
.attr("width",width)
.attr("height",height)
.attr("fill","black")
.attr("x",x)
.attr("y",y)
var text1 = g.append("text")
.attr("fill","red")
.attr("x",x)
.attr("y",y)
.attr("font-size",font_size)
.text("Heyg|gggggggggggrrrrrrrrwerwegggfdfgf")
.style('dominant-baseline','text-before-edge')
.style('font-family','')
var boundingBoxOfTextNode = text1.node().getBBox();
var textLength = text1.node().getComputedTextLength();
var a = width;
var b = font_size;
var c = textLength;
text1.attr("font-size",a * (b/c))
console.log(textLength/boundingBoxOfTextNode.height,width/height)
var a = height;
var b = font_size;
var c = boundingBoxOfTextNode.height ;
text1.attr("font-size",a * (b/c))
console.log(textLength/boundingBoxOfTextNode.height,width/height)
var a = width;
var b = font_size;
var c = textLength;
text1.attr("font-size",a * (b/c))
console.log(textLength/boundingBoxOfTextNode.height,width/height)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment