Created
January 11, 2015 22:58
-
-
Save Radcliffe/85c4243f35aeac76a5a4 to your computer and use it in GitHub Desktop.
myPlot
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='//cdnjs.cloudflare.com/ajax/libs/nvd3/1.1.15-beta/nv.d3.min.css'> | |
<script src='//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js' type='text/javascript'></script> | |
<script src='//d3js.org/d3.v3.min.js' type='text/javascript'></script> | |
<script src='//cdnjs.cloudflare.com/ajax/libs/nvd3/1.1.15-beta/nv.d3.min.js' type='text/javascript'></script> | |
<script src='//nvd3.org/assets/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 = 'chart6aba1a7cba94' class = 'rChart nvd3'></div> | |
<script type='text/javascript'> | |
$(document).ready(function(){ | |
drawchart6aba1a7cba94() | |
}); | |
function drawchart6aba1a7cba94(){ | |
var opts = { | |
"dom": "chart6aba1a7cba94", | |
"width": 800, | |
"height": 400, | |
"x": "Hair", | |
"y": "Freq", | |
"group": "Eye", | |
"type": "multiBarChart", | |
"id": "chart6aba1a7cba94" | |
}, | |
data = [ | |
{ | |
"Hair": "Black", | |
"Eye": "Brown", | |
"Sex": "Male", | |
"Freq": 32 | |
}, | |
{ | |
"Hair": "Brown", | |
"Eye": "Brown", | |
"Sex": "Male", | |
"Freq": 53 | |
}, | |
{ | |
"Hair": "Red", | |
"Eye": "Brown", | |
"Sex": "Male", | |
"Freq": 10 | |
}, | |
{ | |
"Hair": "Blond", | |
"Eye": "Brown", | |
"Sex": "Male", | |
"Freq": 3 | |
}, | |
{ | |
"Hair": "Black", | |
"Eye": "Blue", | |
"Sex": "Male", | |
"Freq": 11 | |
}, | |
{ | |
"Hair": "Brown", | |
"Eye": "Blue", | |
"Sex": "Male", | |
"Freq": 50 | |
}, | |
{ | |
"Hair": "Red", | |
"Eye": "Blue", | |
"Sex": "Male", | |
"Freq": 10 | |
}, | |
{ | |
"Hair": "Blond", | |
"Eye": "Blue", | |
"Sex": "Male", | |
"Freq": 30 | |
}, | |
{ | |
"Hair": "Black", | |
"Eye": "Hazel", | |
"Sex": "Male", | |
"Freq": 10 | |
}, | |
{ | |
"Hair": "Brown", | |
"Eye": "Hazel", | |
"Sex": "Male", | |
"Freq": 25 | |
}, | |
{ | |
"Hair": "Red", | |
"Eye": "Hazel", | |
"Sex": "Male", | |
"Freq": 7 | |
}, | |
{ | |
"Hair": "Blond", | |
"Eye": "Hazel", | |
"Sex": "Male", | |
"Freq": 5 | |
}, | |
{ | |
"Hair": "Black", | |
"Eye": "Green", | |
"Sex": "Male", | |
"Freq": 3 | |
}, | |
{ | |
"Hair": "Brown", | |
"Eye": "Green", | |
"Sex": "Male", | |
"Freq": 15 | |
}, | |
{ | |
"Hair": "Red", | |
"Eye": "Green", | |
"Sex": "Male", | |
"Freq": 7 | |
}, | |
{ | |
"Hair": "Blond", | |
"Eye": "Green", | |
"Sex": "Male", | |
"Freq": 8 | |
}, | |
{ | |
"Hair": "Black", | |
"Eye": "Brown", | |
"Sex": "Female", | |
"Freq": 36 | |
}, | |
{ | |
"Hair": "Brown", | |
"Eye": "Brown", | |
"Sex": "Female", | |
"Freq": 66 | |
}, | |
{ | |
"Hair": "Red", | |
"Eye": "Brown", | |
"Sex": "Female", | |
"Freq": 16 | |
}, | |
{ | |
"Hair": "Blond", | |
"Eye": "Brown", | |
"Sex": "Female", | |
"Freq": 4 | |
}, | |
{ | |
"Hair": "Black", | |
"Eye": "Blue", | |
"Sex": "Female", | |
"Freq": 9 | |
}, | |
{ | |
"Hair": "Brown", | |
"Eye": "Blue", | |
"Sex": "Female", | |
"Freq": 34 | |
}, | |
{ | |
"Hair": "Red", | |
"Eye": "Blue", | |
"Sex": "Female", | |
"Freq": 7 | |
}, | |
{ | |
"Hair": "Blond", | |
"Eye": "Blue", | |
"Sex": "Female", | |
"Freq": 64 | |
}, | |
{ | |
"Hair": "Black", | |
"Eye": "Hazel", | |
"Sex": "Female", | |
"Freq": 5 | |
}, | |
{ | |
"Hair": "Brown", | |
"Eye": "Hazel", | |
"Sex": "Female", | |
"Freq": 29 | |
}, | |
{ | |
"Hair": "Red", | |
"Eye": "Hazel", | |
"Sex": "Female", | |
"Freq": 7 | |
}, | |
{ | |
"Hair": "Blond", | |
"Eye": "Hazel", | |
"Sex": "Female", | |
"Freq": 5 | |
}, | |
{ | |
"Hair": "Black", | |
"Eye": "Green", | |
"Sex": "Female", | |
"Freq": 2 | |
}, | |
{ | |
"Hair": "Brown", | |
"Eye": "Green", | |
"Sex": "Female", | |
"Freq": 14 | |
}, | |
{ | |
"Hair": "Red", | |
"Eye": "Green", | |
"Sex": "Female", | |
"Freq": 7 | |
}, | |
{ | |
"Hair": "Blond", | |
"Eye": "Green", | |
"Sex": "Female", | |
"Freq": 8 | |
} | |
] | |
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] }) | |
} | |
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