A basic HTML bar chart. Part of the Let’s Make a Bar Chart tutorial.
forked from mbostock's block: Bar Chart I
forked from sandravizmad's block: Bar Chart I
forked from sandravizmad's block: Bar Chart I
license: gpl-3.0 |
A basic HTML bar chart. Part of the Let’s Make a Bar Chart tutorial.
forked from mbostock's block: Bar Chart I
forked from sandravizmad's block: Bar Chart I
forked from sandravizmad's block: Bar Chart I
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
.chart div { | |
font: 18px sans-serif; | |
background-color: #40E0D0; | |
text-align: right; | |
padding: 20px; | |
margin: 5px; | |
color: white; | |
} | |
body { | |
background-color: black; | |
} | |
</style> | |
<div class="chart"></div> | |
<script src="//d3js.org/d3.v3.min.js"></script> | |
<script> | |
var data = [4, 8, 15, 16, 23, 42, 60]; | |
var x = d3.scale.linear() | |
.domain([0, d3.max(data)]) | |
.range([0, 300]); | |
d3.select(".chart") | |
.selectAll("div") | |
.data(data) | |
.enter().append("div") | |
.style("width", function(d) { return x(d) + "px"; }) | |
.text(function(d) { return d; }); | |
</script> |