Skip to content

Instantly share code, notes, and snippets.

@35degrees
Last active June 20, 2017 17:36
Show Gist options
  • Save 35degrees/7e9397a80add2f981127f0461dca2e87 to your computer and use it in GitHub Desktop.
Save 35degrees/7e9397a80add2f981127f0461dca2e87 to your computer and use it in GitHub Desktop.
textLength, spacingandglyphs example
license: mit
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
.dot {fill: IndianRed; stroke: LimeGreen; stroke-width: 3px}
.dot:hover {r: 12; stroke-width: 5px}
</style>
</head>
<body>
<script>
// Feel free to change or delete any of the code you see in this editor!
var holder = d3.select("body")
.append("svg")
.attr("width",450)
.attr("height",400);
holder.append("text")
.attr("text-anchor","middle")
.attr("dy","1em")
.text("that's the way")
.attr("textLength",200)
.attr("lengthAdjust", "spacingAndGlyphs")
.attr("transform","translate(200,200) scale(2) rotate(20)")
holder.append("polyline")
.style("fill","none")
.style("stroke","MidnightBlue")
.attr("points"," 200,25, 200,300");
holder.append("polyline")
.style("fill","none")
.style("stroke","MidnightBlue")
.attr("points"," 25,200, 300,200");
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment