Skip to content

Instantly share code, notes, and snippets.

@renecnielsen
Created November 1, 2013 18:15
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 renecnielsen/7269488 to your computer and use it in GitHub Desktop.
Save renecnielsen/7269488 to your computer and use it in GitHub Desktop.
Kenya Events 2007
<!doctype HTML>
<html>
<head>
<link rel='stylesheet' href='http://nvd3.org/src/nv.d3.css'>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js' type='text/javascript'></script>
<script src='http://d3js.org/d3.v2.min.js' type='text/javascript'></script>
<script src='http://nvd3.org/nv.d3.js' type='text/javascript'></script>
<script src='http://nvd3.org/lib/fisheye.js' type='text/javascript'></script>
<style>
.rChart {
display: block;
margin-left: auto;
margin-right: auto;
width: 800px;
height: 400px;
}
</style>
</head>
<body>
<div id='chart8def2a8413b0' class='rChart nvd3'></div>
<script type='text/javascript'>
$(document).ready(function(){
drawchart8def2a8413b0()
});
function drawchart8def2a8413b0(){
var opts = {
"dom": "chart8def2a8413b0",
"width": 800,
"height": 400,
"x": "month",
"y": "count",
"group": "QuadClass",
"type": "lineChart",
"id": "chart8def2a8413b0"
},
data = [
{
"month": 2007.9,
"QuadClass": "Verbal Cooperation",
"count": 3133
},
{
"month": 2007.9,
"QuadClass": "Material Cooperation",
"count": 487
},
{
"month": 2007.9,
"QuadClass": "Verbal Conflict",
"count": 903
},
{
"month": 2007.9,
"QuadClass": "Material Conflict",
"count": 838
}
]
var data = d3.nest()
.key(function(d){
return opts.group === undefined ? 'main' : d[opts.group]
})
.entries(data)
nv.addGraph(function() {
var chart = nv.models[opts.type]()
.x(function(d) { return d[opts.x] })
.y(function(d) { return d[opts.y] })
.width(opts.width)
.height(opts.height)
d3.select("#" + opts.id)
.append('svg')
.datum(data)
.transition().duration(500)
.call(chart);
nv.utils.windowResize(chart.update);
return chart;
});
};
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment