Skip to content

Instantly share code, notes, and snippets.

@fogonwater
Last active December 7, 2017 01:38
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 fogonwater/812b3e2f10ea60a7a03a7c71ba15b6b1 to your computer and use it in GitHub Desktop.
Save fogonwater/812b3e2f10ea60a7a03a7c71ba15b6b1 to your computer and use it in GitHub Desktop.
chroma d3 tests
license: mit
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chroma-js/1.3.4/chroma.min.js"></script>
<style>
body { margin:0;top:0;right:0;bottom:0;left:0; }
div {
color: #444;
float: left;
font-family: sans-serif;
font-size: 0.8em;
margin: 1px;
padding: 4px;
width: 75px;
height: 70px;
}
</style>
</head>
<body>
<script>
const num_cols = 66,
data = d3.range(0,num_cols),
color = chroma
.scale(['#fafa6e','#2A4858'])
.mode('lch')
.colors(num_cols)
d3.select("body").selectAll("div")
.data(data)
.enter().append("div")
.style("background", function(d) {return color[d]})
.text(function(d){ return color[d]; })
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment