Skip to content

Instantly share code, notes, and snippets.

Created October 23, 2017 15:53
What would you like to do?
fresh block
license: mit
<!DOCTYPE html>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<style type="text/css" media="screen">
div {
height: 60px;
float: left;
margin: 1px;
<svg width="500"></svg>
<script src=""></script>
<script src=""></script>
<script type="text/javascript">
var body ="body"),
length = 100,
color = d3.scale.linear().domain([1,length])
.range([d3.rgb("#007AFF"), d3.rgb('#FFF500')]);
for (var i = 0; i < length; i++) {
body.append('div').attr('style', function (d) {
return 'background-color: ' + color(i);
var svg ="svg");
var data = d3.range(50);
var rects = svg.selectAll(".rects")
.attr("y", 10)
.attr("height", 100)
.attr("x", (d,i)=>10 + i*9)
.attr("width", 6)
.attr("fill", d=>color(d))
.attr("stroke", "gray");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment