-
-
Save ashumeow/7437560 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype HTML> | |
<meta charset ="UTF-8"> | |
<html> | |
<head> | |
<link rel='stylesheet' type="text/css" 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='chart188538586f7' class='rChart nvd3'></div> | |
<script type='text/javascript'> | |
$(document).ready(function(){ | |
drawchart188538586f7() | |
}); | |
function drawchart188538586f7(){ | |
var opts = { | |
"dom": "chart188538586f7", | |
"width": 800, | |
"height": 400, | |
"x": "Year", | |
"y": "value", | |
"group": "variable", | |
"type": "multiBarChart", | |
"id": "chart188538586f7" | |
}, | |
data = [ | |
{ | |
"Year": "2005", | |
"variable": "L_to_others", | |
"value": 15 | |
}, | |
{ | |
"Year": "2006", | |
"variable": "L_to_others", | |
"value": 16 | |
}, | |
{ | |
"Year": "2007", | |
"variable": "L_to_others", | |
"value": 21 | |
}, | |
{ | |
"Year": "2008", | |
"variable": "L_to_others", | |
"value": 15 | |
}, | |
{ | |
"Year": "2009", | |
"variable": "L_to_others", | |
"value": 12 | |
}, | |
{ | |
"Year": "2010", | |
"variable": "L_to_others", | |
"value": 12 | |
}, | |
{ | |
"Year": "2011", | |
"variable": "L_to_others", | |
"value": 13 | |
}, | |
{ | |
"Year": "2012", | |
"variable": "L_to_others", | |
"value": 9 | |
}, | |
{ | |
"Year": "2013", | |
"variable": "L_to_others", | |
"value": 11 | |
}, | |
{ | |
"Year": "2005", | |
"variable": "L_vs_top_10", | |
"value": 1 | |
}, | |
{ | |
"Year": "2006", | |
"variable": "L_vs_top_10", | |
"value": 8 | |
}, | |
{ | |
"Year": "2007", | |
"variable": "L_vs_top_10", | |
"value": 3 | |
}, | |
{ | |
"Year": "2008", | |
"variable": "L_vs_top_10", | |
"value": 6 | |
}, | |
{ | |
"Year": "2009", | |
"variable": "L_vs_top_10", | |
"value": 8 | |
}, | |
{ | |
"Year": "2010", | |
"variable": "L_vs_top_10", | |
"value": 7 | |
}, | |
{ | |
"Year": "2011", | |
"variable": "L_vs_top_10", | |
"value": 7 | |
}, | |
{ | |
"Year": "2012", | |
"variable": "L_vs_top_10", | |
"value": 11 | |
}, | |
{ | |
"Year": "2013", | |
"variable": "L_vs_top_10", | |
"value": 12 | |
}, | |
{ | |
"Year": "2005", | |
"variable": "W_over_others", | |
"value": 15 | |
}, | |
{ | |
"Year": "2006", | |
"variable": "W_over_others", | |
"value": 30 | |
}, | |
{ | |
"Year": "2007", | |
"variable": "W_over_others", | |
"value": 20 | |
}, | |
{ | |
"Year": "2008", | |
"variable": "W_over_others", | |
"value": 34 | |
}, | |
{ | |
"Year": "2009", | |
"variable": "W_over_others", | |
"value": 29 | |
}, | |
{ | |
"Year": "2010", | |
"variable": "W_over_others", | |
"value": 34 | |
}, | |
{ | |
"Year": "2011", | |
"variable": "W_over_others", | |
"value": 32 | |
}, | |
{ | |
"Year": "2012", | |
"variable": "W_over_others", | |
"value": 33 | |
}, | |
{ | |
"Year": "2013", | |
"variable": "W_over_others", | |
"value": 42 | |
}, | |
{ | |
"Year": "2005", | |
"variable": "W_vs_top_10", | |
"value": 1 | |
}, | |
{ | |
"Year": "2006", | |
"variable": "W_vs_top_10", | |
"value": 3 | |
}, | |
{ | |
"Year": "2007", | |
"variable": "W_vs_top_10", | |
"value": 1 | |
}, | |
{ | |
"Year": "2008", | |
"variable": "W_vs_top_10", | |
"value": 4 | |
}, | |
{ | |
"Year": "2009", | |
"variable": "W_vs_top_10", | |
"value": 2 | |
}, | |
{ | |
"Year": "2010", | |
"variable": "W_vs_top_10", | |
"value": 2 | |
}, | |
{ | |
"Year": "2011", | |
"variable": "W_vs_top_10", | |
"value": 3 | |
}, | |
{ | |
"Year": "2012", | |
"variable": "W_vs_top_10", | |
"value": 2 | |
}, | |
{ | |
"Year": "2013", | |
"variable": "W_vs_top_10", | |
"value": 9 | |
} | |
] | |
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) | |
chart | |
.reduceXTicks(false) | |
chart.xAxis | |
.staggerLabels(false) | |
chart.yAxis | |
.tickFormat( function(d) {return + d} ) | |
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