Skip to content

Instantly share code, notes, and snippets.

@gujc71
Last active March 22, 2017 11:50
Show Gist options
  • Save gujc71/45c9b03a6355a7cc7ab1112907ae9a12 to your computer and use it in GitHub Desktop.
Save gujc71/45c9b03a6355a7cc7ab1112907ae9a12 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<meta charset="utf-8">
<svg width="500" height="300"></svg>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script>
var dataset = [9, 19, 29, 39, 29, 19, 9];
var svg = d3.select("svg");
svg.selectAll("bar")
.data(dataset)
.enter().append("rect")
.attr("height", function(d, i) {return d})
.attr("width", 40)
.attr("x", function(d, i) {return (50 * i)})
.attr("y", function(d, i) {return (100 - dataset[i])});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment