.DS_Store
# use-d3-v3-to-build-interactive-charts-with-javascript
body {
padding-top: 50px;
padding-left: 100px;
}
#chartArea {
width: 400px;
height: 300px;
background-color: #CCC;
}
.bar {
display: inline-block;
/* Gets overriden by D3-assigned height below */
margin-right: 2px;
fill: teal;
}
<!DOCTYPE html>
<html>
<head>
<title>D3 - Data Driven Documents</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.16/d3.js"></script>
<link rel="stylesheet" href="./app.css">
</head>
<body>
<div id="chartArea"></div>
<script src="script.js"></script>
</body>
</html>
var dataset = [ 5, 10, 15, 20, 25 ];
var svg = d3.select('#chartArea').append('svg')
.attr('width', 400)
.attr('height', 300);
var multiplier = 8;
svg.selectAll('rect')
.data(dataset)
.enter()
.append('rect')
.attr('class', 'bar')
.attr('x', function (d, i) {
return i * 22;
})
.attr('y', function (d) {
return 300 - d * multiplier;
})
.attr('width', 20)
.attr('height', function (d) {
return d * multiplier;
});