Skip to content

Instantly share code, notes, and snippets.

@aaizemberg
Created July 25, 2015 13:38
Show Gist options
  • Save aaizemberg/b77e897ec9dcf1c53118 to your computer and use it in GitHub Desktop.
Save aaizemberg/b77e897ec9dcf1c53118 to your computer and use it in GitHub Desktop.
Gráfico de barras con DIVs desde D3.js
<!DOCTYPE html>
<head>
<script src="http://d3js.org/d3.v3.min.js"></script>
<style>
.chart div {
font: 10px sans-serif;
background-color: green;
text-align: right;
padding: 3px;
margin: 1px;
color: white;
}
</style>
</head>
<body>
<div class="chart"></div>
<script>
var v = [4,8,15,16,23,42];
d3.select("div.chart")
.selectAll("div").data(v).enter().append("div")
.text( function(d,i) { return d; } )
.attr("style", function(d,i) { return "width: "+d*10+"px;"; } );
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment