Skip to content

Instantly share code, notes, and snippets.

@floofydugong
Last active October 19, 2016 16:51
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 floofydugong/b79526bd3617fd6aa9d9cd901ebcc57b to your computer and use it in GitHub Desktop.
Save floofydugong/b79526bd3617fd6aa9d9cd901ebcc57b to your computer and use it in GitHub Desktop.
Bar Chart I (Practice)
<!DOCTYPE html>
<meta charset="utf-8">
<style type="text/css">
.chart div {
font: 10px san-serif;
background-color: steelblue;
text-align: right;
padding: 3px;
margin: 1px;
color: white;
}
</style>
<div class="chart"></div>
<script src="//d3js.org/d3.v3.min.js"></script>
<script>
var data = [4,8,15,16,23,42];
var x = d3.scale.linear()
.domain([0,d3.max(data)])
.range([0,420]);
d3.select(".chart")
.selectAll("div")
.data (data)
.enter().append("div")
.style("width", function(d){ return x(d) + "px";})
.text(function(d) {return d;});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment