Created
August 26, 2014 18:31
-
-
Save patilv/8d97301722fd8413a9e9 to your computer and use it in GitHub Desktop.
np1nationality
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' href='http://nvd3.org/assets/css/nv.d3.css'> | |
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js' type='text/javascript'></script> | |
<script src='http://d3js.org/d3.v3.min.js' type='text/javascript'></script> | |
<script src='http://timelyportfolio.github.io/rCharts_nvd3_tests/libraries/widgets/nvd3/js/nv.d3.min-new.js' type='text/javascript'></script> | |
<script src='http://nvd3.org/assets/lib/fisheye.js' type='text/javascript'></script> | |
<style> | |
.rChart { | |
display: block; | |
margin-left: auto; | |
margin-right: auto; | |
width: 800px; | |
height: 1000px; | |
} | |
</style> | |
</head> | |
<body > | |
<div id = 'chart25e860a53520' class = 'rChart nvd3'></div> | |
<script type='text/javascript'> | |
$(document).ready(function(){ | |
drawchart25e860a53520() | |
}); | |
function drawchart25e860a53520(){ | |
var opts = { | |
"dom": "chart25e860a53520", | |
"width": 800, | |
"height": 1000, | |
"x": "country", | |
"y": "count", | |
"group": "gender", | |
"type": "multiBarHorizontalChart", | |
"stacked": false, | |
"id": "chart25e860a53520" | |
}, | |
data = [ | |
{ | |
"country": "Argentina", | |
"gender": "Female", | |
"count": 1 | |
}, | |
{ | |
"country": "Argentina", | |
"gender": "Male", | |
"count": 7 | |
}, | |
{ | |
"country": "Australia", | |
"gender": "Female", | |
"count": 6 | |
}, | |
{ | |
"country": "Australia", | |
"gender": "Male", | |
"count": 6 | |
}, | |
{ | |
"country": "Austria", | |
"gender": "Female", | |
"count": 2 | |
}, | |
{ | |
"country": "Austria", | |
"gender": "Male", | |
"count": 3 | |
}, | |
{ | |
"country": "Belarus", | |
"gender": "Female", | |
"count": 3 | |
}, | |
{ | |
"country": "Belarus", | |
"gender": "Male", | |
"count": 0 | |
}, | |
{ | |
"country": "Belgium", | |
"gender": "Female", | |
"count": 3 | |
}, | |
{ | |
"country": "Belgium", | |
"gender": "Male", | |
"count": 3 | |
}, | |
{ | |
"country": "Bosnia", | |
"gender": "Female", | |
"count": 0 | |
}, | |
{ | |
"country": "Bosnia", | |
"gender": "Male", | |
"count": 1 | |
}, | |
{ | |
"country": "Brazil", | |
"gender": "Female", | |
"count": 1 | |
}, | |
{ | |
"country": "Brazil", | |
"gender": "Male", | |
"count": 1 | |
}, | |
{ | |
"country": "Bulgaria", | |
"gender": "Female", | |
"count": 1 | |
}, | |
{ | |
"country": "Bulgaria", | |
"gender": "Male", | |
"count": 1 | |
}, | |
{ | |
"country": "Canada", | |
"gender": "Female", | |
"count": 4 | |
}, | |
{ | |
"country": "Canada", | |
"gender": "Male", | |
"count": 3 | |
}, | |
{ | |
"country": "China", | |
"gender": "Female", | |
"count": 6 | |
}, | |
{ | |
"country": "China", | |
"gender": "Male", | |
"count": 0 | |
}, | |
{ | |
"country": "Colombia", | |
"gender": "Female", | |
"count": 0 | |
}, | |
{ | |
"country": "Colombia", | |
"gender": "Male", | |
"count": 3 | |
}, | |
{ | |
"country": "Croatia", | |
"gender": "Female", | |
"count": 2 | |
}, | |
{ | |
"country": "Croatia", | |
"gender": "Male", | |
"count": 4 | |
}, | |
{ | |
"country": "Cypress", | |
"gender": "Female", | |
"count": 0 | |
}, | |
{ | |
"country": "Cypress", | |
"gender": "Male", | |
"count": 1 | |
}, | |
{ | |
"country": "Czech Republic", | |
"gender": "Female", | |
"count": 8 | |
}, | |
{ | |
"country": "Czech Republic", | |
"gender": "Male", | |
"count": 4 | |
}, | |
{ | |
"country": "Denmark", | |
"gender": "Female", | |
"count": 1 | |
}, | |
{ | |
"country": "Denmark", | |
"gender": "Male", | |
"count": 0 | |
}, | |
{ | |
"country": "Dominican Republic", | |
"gender": "Female", | |
"count": 0 | |
}, | |
{ | |
"country": "Dominican Republic", | |
"gender": "Male", | |
"count": 1 | |
}, | |
{ | |
"country": "Estonia", | |
"gender": "Female", | |
"count": 1 | |
}, | |
{ | |
"country": "Estonia", | |
"gender": "Male", | |
"count": 0 | |
}, | |
{ | |
"country": "Finland", | |
"gender": "Female", | |
"count": 0 | |
}, | |
{ | |
"country": "Finland", | |
"gender": "Male", | |
"count": 1 | |
}, | |
{ | |
"country": "France", | |
"gender": "Female", | |
"count": 6 | |
}, | |
{ | |
"country": "France", | |
"gender": "Male", | |
"count": 13 | |
}, | |
{ | |
"country": "Germany", | |
"gender": "Female", | |
"count": 6 | |
}, | |
{ | |
"country": "Germany", | |
"gender": "Male", | |
"count": 8 | |
}, | |
{ | |
"country": "Great Britain", | |
"gender": "Female", | |
"count": 2 | |
}, | |
{ | |
"country": "Great Britain", | |
"gender": "Male", | |
"count": 1 | |
}, | |
{ | |
"country": "Hungary", | |
"gender": "Female", | |
"count": 1 | |
}, | |
{ | |
"country": "Hungary", | |
"gender": "Male", | |
"count": 0 | |
}, | |
{ | |
"country": "Ireland", | |
"gender": "Female", | |
"count": 0 | |
}, | |
{ | |
"country": "Ireland", | |
"gender": "Male", | |
"count": 1 | |
}, | |
{ | |
"country": "Israel", | |
"gender": "Female", | |
"count": 2 | |
}, | |
{ | |
"country": "Israel", | |
"gender": "Male", | |
"count": 1 | |
}, | |
{ | |
"country": "Italy", | |
"gender": "Female", | |
"count": 6 | |
}, | |
{ | |
"country": "Italy", | |
"gender": "Male", | |
"count": 4 | |
}, | |
{ | |
"country": "Japan", | |
"gender": "Female", | |
"count": 3 | |
}, | |
{ | |
"country": "Japan", | |
"gender": "Male", | |
"count": 4 | |
}, | |
{ | |
"country": "Kazakhstan", | |
"gender": "Female", | |
"count": 2 | |
}, | |
{ | |
"country": "Kazakhstan", | |
"gender": "Male", | |
"count": 3 | |
}, | |
{ | |
"country": "Latvia", | |
"gender": "Female", | |
"count": 0 | |
}, | |
{ | |
"country": "Latvia", | |
"gender": "Male", | |
"count": 1 | |
}, | |
{ | |
"country": "Luxembourg", | |
"gender": "Female", | |
"count": 0 | |
}, | |
{ | |
"country": "Luxembourg", | |
"gender": "Male", | |
"count": 1 | |
}, | |
{ | |
"country": "Moldova", | |
"gender": "Female", | |
"count": 0 | |
}, | |
{ | |
"country": "Moldova", | |
"gender": "Male", | |
"count": 1 | |
}, | |
{ | |
"country": "Netherlands", | |
"gender": "Female", | |
"count": 1 | |
}, | |
{ | |
"country": "Netherlands", | |
"gender": "Male", | |
"count": 2 | |
}, | |
{ | |
"country": "New Zealand", | |
"gender": "Female", | |
"count": 1 | |
}, | |
{ | |
"country": "New Zealand", | |
"gender": "Male", | |
"count": 0 | |
}, | |
{ | |
"country": "Poland", | |
"gender": "Female", | |
"count": 3 | |
}, | |
{ | |
"country": "Poland", | |
"gender": "Male", | |
"count": 1 | |
}, | |
{ | |
"country": "Portugal", | |
"gender": "Female", | |
"count": 0 | |
}, | |
{ | |
"country": "Portugal", | |
"gender": "Male", | |
"count": 1 | |
}, | |
{ | |
"country": "Puerto Rico", | |
"gender": "Female", | |
"count": 1 | |
}, | |
{ | |
"country": "Puerto Rico", | |
"gender": "Male", | |
"count": 0 | |
}, | |
{ | |
"country": "Romania", | |
"gender": "Female", | |
"count": 5 | |
}, | |
{ | |
"country": "Romania", | |
"gender": "Male", | |
"count": 0 | |
}, | |
{ | |
"country": "Russia", | |
"gender": "Female", | |
"count": 8 | |
}, | |
{ | |
"country": "Russia", | |
"gender": "Male", | |
"count": 6 | |
}, | |
{ | |
"country": "Serbia", | |
"gender": "Female", | |
"count": 4 | |
}, | |
{ | |
"country": "Serbia", | |
"gender": "Male", | |
"count": 3 | |
}, | |
{ | |
"country": "Slovakia", | |
"gender": "Female", | |
"count": 6 | |
}, | |
{ | |
"country": "Slovakia", | |
"gender": "Male", | |
"count": 4 | |
}, | |
{ | |
"country": "South Africa", | |
"gender": "Female", | |
"count": 1 | |
}, | |
{ | |
"country": "South Africa", | |
"gender": "Male", | |
"count": 1 | |
}, | |
{ | |
"country": "Spain", | |
"gender": "Female", | |
"count": 4 | |
}, | |
{ | |
"country": "Spain", | |
"gender": "Male", | |
"count": 13 | |
}, | |
{ | |
"country": "Sweden", | |
"gender": "Female", | |
"count": 1 | |
}, | |
{ | |
"country": "Sweden", | |
"gender": "Male", | |
"count": 0 | |
}, | |
{ | |
"country": "Switzerland", | |
"gender": "Female", | |
"count": 4 | |
}, | |
{ | |
"country": "Switzerland", | |
"gender": "Male", | |
"count": 3 | |
}, | |
{ | |
"country": "Taiwan", | |
"gender": "Female", | |
"count": 1 | |
}, | |
{ | |
"country": "Taiwan", | |
"gender": "Male", | |
"count": 1 | |
}, | |
{ | |
"country": "Tunisia", | |
"gender": "Female", | |
"count": 1 | |
}, | |
{ | |
"country": "Tunisia", | |
"gender": "Male", | |
"count": 0 | |
}, | |
{ | |
"country": "Ukraine", | |
"gender": "Female", | |
"count": 3 | |
}, | |
{ | |
"country": "Ukraine", | |
"gender": "Male", | |
"count": 2 | |
}, | |
{ | |
"country": "Uruguay", | |
"gender": "Female", | |
"count": 0 | |
}, | |
{ | |
"country": "Uruguay", | |
"gender": "Male", | |
"count": 1 | |
}, | |
{ | |
"country": "USA", | |
"gender": "Female", | |
"count": 17 | |
}, | |
{ | |
"country": "USA", | |
"gender": "Male", | |
"count": 12 | |
}, | |
{ | |
"country": "Uzbekistan", | |
"gender": "Female", | |
"count": 0 | |
}, | |
{ | |
"country": "Uzbekistan", | |
"gender": "Male", | |
"count": 1 | |
} | |
] | |
if(!(opts.type==="pieChart" || opts.type==="sparklinePlus" || opts.type==="bulletChart")) { | |
var data = d3.nest() | |
.key(function(d){ | |
//return opts.group === undefined ? 'main' : d[opts.group] | |
//instead of main would think a better default is opts.x | |
return opts.group === undefined ? opts.y : d[opts.group]; | |
}) | |
.entries(data); | |
} | |
if (opts.disabled != undefined){ | |
data.map(function(d, i){ | |
d.disabled = opts.disabled[i] | |
}) | |
} | |
nv.addGraph(function() { | |
var chart = nv.models[opts.type]() | |
.width(opts.width) | |
.height(opts.height) | |
if (opts.type != "bulletChart"){ | |
chart | |
.x(function(d) { return d[opts.x] }) | |
.y(function(d) { return d[opts.y] }) | |
} | |
chart | |
.margin({ | |
"top": 30, | |
"right": 20, | |
"bottom": 20, | |
"left": 150 | |
}) | |
.color([ "#FF4444", "#002865" ]) | |
d3.select("#" + opts.id) | |
.append('svg') | |
.datum(data) | |
.transition().duration(500) | |
.call(chart); | |
nv.utils.windowResize(chart.update); | |
return chart; | |
}); | |
}; | |
</script> | |
<script></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment