Built with blockbuilder.org
Last active
April 9, 2017 21:27
-
-
Save trinary/88d9c034bbae77cb6560e70533ceecc8 to your computer and use it in GitHub Desktop.
simple bars, not quite right
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> | |
<head> | |
<meta charset="utf-8"> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.7.4/d3.min.js"></script> | |
<style> | |
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } | |
svg { width:100%; height: 100% } | |
</style> | |
</head> | |
<body> | |
<svg></svg> | |
<script> | |
var data = [ | |
{value: 7}, | |
{value: 20}, | |
{value: 33}, | |
{value: 9}, | |
{value: 1}, | |
{value: 44}, | |
{value: 15}, | |
{value: 26} | |
]; | |
var svg = d3.select("svg"); | |
var bars = svg.selectAll(".bars") | |
.data(data); | |
// !!! Uncomment the stuff below to see some bars! | |
/* | |
bars.enter() | |
.append("rect") | |
.classed("bars", true) | |
.attr("x", function(d,i) { return 20 + (i * 40)}) | |
.attr("y", 100) | |
.attr("width", 20) | |
.attr("height", function(d,i) { return d.value * 5;}) | |
.style("fill","grey") | |
*/ | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment