Skip to content

Instantly share code, notes, and snippets.

@chmille4
Last active December 17, 2015 19:36
Show Gist options
  • Save chmille4/31d892d71e66e63bbf4f to your computer and use it in GitHub Desktop.
Save chmille4/31d892d71e66e63bbf4f to your computer and use it in GitHub Desktop.
Iobio.viz Bar Chart
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js" charset="utf-8"></script>
<script src="http://iobio.io/public/js/iobio.viz.min.js"></script>
<link rel="stylesheet" type="text/css" href="http://iobio.io/public/css/iobio.viz.min.css">
<style type="text/css">
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
margin: auto;
position: relative;
width: 960px;
}
#bar-viz .iobio-bar rect { fill: rgb(120,176,194); }
</style>
</head>
<body>
<div id="bar-viz"></div>
<script>
var m = [30, 60, 44, 70],
w = 960,
h = 500;
var barData = [ [0, 4], [1,1], [3,3], [6,4], [12,2], [18,7], [23,1], [25,2], [30,1], [36,1], [40,5], [41,3] ];
var selection = d3.select("#bar-viz").datum( barData );
var barChart = iobio.viz.bar()
.xValue(function(d) { return d[0]; })
.yValue(function(d) { return d[1]; })
.wValue(function() { return 1; })
.height(h)
.width(w)
.margin({top: m[0], right: m[1], bottom: m[2], left:m[3]})
.tooltip(function(d) { return d[0]})
barChart( selection );
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment