I am trying to create a basic column chart using divs from the example in allignedleft and the one mike has posted. The chart works except when i add text, it inverses.
<!DOCTYPE html>
<head>
<style type="text/css">
div.abc {
display: inline-block;
width: 20px;
height: 75px;
background-color: teal;
margin-right: 2px;
}
</style>
</head>
<body>
<script type="text/javascript" src="http://d3js.org/d3.v2.js?2.8.1"></script>
<script>
var dataset = [16,13,8,2,1,10,0,5,24,15,2,6,12];
d3.select("body").selectAll("div")
.data(dataset)
.enter()
.append("div")
.attr("class", "abc")
.style("height", function(d) {
var barHeight = d * 5;
return barHeight + "px";
})
.style("margin-top",function(d) {
var barHeight = d * 5;
return 500 - barHeight;
})
.style("text-align","center")
.style("color","black")
.text(function (d) { return d; });
</script>
</body>
</html>
thanks
Sriram