Created
January 2, 2013 03:23
-
-
Save levibrown/4431866 to your computer and use it in GitHub Desktop.
bar chart demo
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
{"description":"bar chart demo","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"tab":"edit","display_percent":0.7,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"hidepanel":false} |
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 svg = d3.select("svg"); | |
var h = 170 | |
var dataset = [ 91, 0, 15, 58, 25 ]; | |
svg.selectAll("rect") | |
.data(dataset) | |
.enter() | |
.append("rect") | |
.attr("x", function(d, i) { | |
return i * 21 + 265; //Bar width of 20 plus 1 for padding | |
}) | |
.attr("y", function(d) { | |
return h - d; //Height minus data value | |
}) | |
.attr("height", function(d, i){ | |
return d + 20; | |
}) | |
.attr("width", 19); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment