Skip to content

Instantly share code, notes, and snippets.

@vicapow
Last active December 23, 2015 21:09
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 vicapow/6694430 to your computer and use it in GitHub Desktop.
Save vicapow/6694430 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
</head>
<body>
<style>
.bar{
height: 10px;
background-color: blue;
border-bottom: 1px solid white;
}
</style>
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
<script>
var data = [10, 30, 60];
d3.selectAll('.bar').style('width', function(d, index){
return data[index] + '%';
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment