Built with blockbuilder.org
Created
October 23, 2017 15:52
-
-
Save anonymous/bc52fec0e10aedb3526d0e195d0274da to your computer and use it in GitHub Desktop.
fresh block
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
license: mit |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<title></title> | |
<style type="text/css" media="screen"> | |
div { | |
width:60px; | |
height: 60px; | |
float: left; | |
margin: 1px; | |
} | |
</style> | |
</head> | |
<body> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> | |
<script src="http://d3js.org/d3.v3.js"></script> | |
<script type="text/javascript"> | |
var body = d3.select("body"), | |
length = 100, | |
color = d3.scale.linear().domain([1,length]) | |
.interpolate(d3.interpolateHcl) | |
.range([d3.rgb("#007AFF"), d3.rgb('#FFF500')]); | |
<svg width="500"></svg> | |
for (var i = 0; i < length; i++) { | |
body.append('div').attr('style', function (d) { | |
return 'background-color: ' + color(i); | |
}); | |
} | |
var svg = d3.select("svg"); | |
var rects = svg.selectAll(".rects") | |
.data(color) | |
.enter() | |
.append("rect") | |
.attr("y", 10) | |
.attr("height", 100) | |
.attr("x", (d,i)=>10 + i*9) | |
.attr("width", 6) | |
.attr("fill", d=>colors(d)) | |
.attr("stroke", "gray"); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment