Skip to content

Instantly share code, notes, and snippets.

@trinary
Last active April 9, 2017 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trinary/88d9c034bbae77cb6560e70533ceecc8 to your computer and use it in GitHub Desktop.
Save trinary/88d9c034bbae77cb6560e70533ceecc8 to your computer and use it in GitHub Desktop.
simple bars, not quite right
license: mit
<!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