Last active
August 29, 2015 14:11
-
-
Save svenhofstede-zz/2848a3c6fe2ddda1c768 to your computer and use it in GitHub Desktop.
Hover_grid_color_bg
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
var canvas = d3.select("svg"); | |
var width = 500; | |
var height = 500; | |
var amount = 12; | |
var data = []; | |
var intervalW = width/amount; | |
var intervalH = height/amount; | |
for (i=0;i<amount;i++){ | |
for (j=0;j<amount;j++){ | |
data.push([i*intervalW,j*intervalH]); | |
} | |
} | |
var canvas = canvas.attr("width",width) | |
.attr("height",height); | |
var g = canvas.append("g"); | |
var rects = g.selectAll("rect") | |
.data(data) | |
.enter() | |
.append("rect") | |
rects | |
.attr("width",width/amount) | |
.attr("height",height/amount) | |
.attr("x",function(d){return d[0]}) | |
.attr("y",function(d){return d[1]}) | |
.attr("fill","#cee2f1") | |
.attr("stroke","grey") | |
rects.on("mouseover",function(){ | |
d3.select(this) | |
.attr("fill","black"); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment