Skip to content

Instantly share code, notes, and snippets.

@enjalot
Created October 11, 2016 16:53
Show Gist options
  • Save enjalot/cd38320d88e41cd2a8d21c1e2eb5b938 to your computer and use it in GitHub Desktop.
Save enjalot/cd38320d88e41cd2a8d21c1e2eb5b938 to your computer and use it in GitHub Desktop.
category10
license: mit
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<link href="https://fonts.googleapis.com/css?family=Droid+Sans+Mono" rel="stylesheet">
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
</style>
</head>
<body>
<script>
var s = "category10"
var color = d3.scaleOrdinal(d3.schemeCategory10)
var svg = d3.select("body").append("svg")
.attr("width", 960)
.attr("height", 500)
svg.append("text")
.attr("y", 250)
.attr("x", 480)
.style("text-anchor", "middle")
.style("font-size", 100)
//.style("font-family", "Droid Sans Mono, Courier, monospace")
.style("font-family", "Courier, monospace")
.selectAll("tspan").data(s.split(''))
.enter()
.append("tspan")
.text(function(d) { return d})
.style("fill", function(d,i) { return color(i) })
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment