Last active
August 29, 2015 14:04
-
-
Save denisinla/7b1ac13ad9e8c0efc43e to your computer and use it in GitHub Desktop.
Messing with D3.
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> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script> | |
<meta charset="utf-8"> | |
<title>Messing with D3</title> | |
</head> | |
<body> | |
<h3>D3 Bar Charts</h3> | |
<div id="barchart"></div> | |
</body> | |
</html> |
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 data = [1,2,3,4,5,4,3,5,2,1]; | |
var svg = d3.select("#barchart") | |
.append("svg") | |
.attr("width","240") | |
.attr("height","100"); | |
svg.selectAll('rect') | |
.data(data) | |
.enter() | |
.append('rect') | |
.attr('x', function(d, i) { return i * 22; }) | |
.attr('y', 100) | |
.attr('width', 20) | |
.attr('height', 0) | |
.transition() | |
.delay(function(d, i) { return i * 100; }) | |
.duration(200) | |
.attr('y', function(d) { return 100 - d * 20; }) | |
.attr('height', function(d) { return d * 20; }); |
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
body{ | |
font: 16px Arial,Helvetica,sans-serif; | |
color: #111; | |
a,a:link,a:active{ | |
color: #333; | |
text-decoration: none; | |
} | |
svg{ | |
fill: #27ae60; | |
} | |
#barchart{ | |
margin: 50px 0 0 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment