<script src='nvd3/js/jquery-1.8.2.min.js' type='text/javascript'></script>
<script src='nvd3/js/d3.v3.min.js' type='text/javascript'></script>
<script src='nvd3/js/nv.d3.min-new.js' type='text/javascript'></script>
<script src='nvd3/js/fisheye.js' type='text/javascript'></script>
<style>
.rChart {
display: block;
margin-left: auto;
margin-right: auto;
width: 800px;
height: 400px;
}
</style>
<div id = 'chartc58797918a0' class = 'rChart nvd3'></div>
<script type='text/javascript'>
$(document).ready(function(){ drawchartc58797918a0() }); function drawchartc58797918a0(){
var opts = { "dom": "chartc58797918a0", "width": 800, "height": 400, "x": "Hair", "y": "Freq", "group": "Eye", "type": "multiBarHorizontalChart", "id": "chartc58797918a0" }, data = [ { "Hair": "HairBlack", "Eye": "EyeBrown", "Sex": "Male", "Freq": 32 }, { "Hair": "HairBrown", "Eye": "EyeBrown", "Sex": "Male", "Freq": 53 }, { "Hair": "HairRed", "Eye": "EyeBrown", "Sex": "Male", "Freq": 10 }, { "Hair": "HairBlond", "Eye": "EyeBrown", "Sex": "Male", "Freq": 3 }, { "Hair": "HairBlack", "Eye": "EyeBlue", "Sex": "Male", "Freq": 11 }, { "Hair": "HairBrown", "Eye": "EyeBlue", "Sex": "Male", "Freq": 50 }, { "Hair": "HairRed", "Eye": "EyeBlue", "Sex": "Male", "Freq": 10 }, { "Hair": "HairBlond", "Eye": "EyeBlue", "Sex": "Male", "Freq": 30 }, { "Hair": "HairBlack", "Eye": "EyeHazel", "Sex": "Male", "Freq": 10 }, { "Hair": "HairBrown", "Eye": "EyeHazel", "Sex": "Male", "Freq": 25 }, { "Hair": "HairRed", "Eye": "EyeHazel", "Sex": "Male", "Freq": 7 }, { "Hair": "HairBlond", "Eye": "EyeHazel", "Sex": "Male", "Freq": 5 }, { "Hair": "HairBlack", "Eye": "EyeGreen", "Sex": "Male", "Freq": 3 }, { "Hair": "HairBrown", "Eye": "EyeGreen", "Sex": "Male", "Freq": 15 }, { "Hair": "HairRed", "Eye": "EyeGreen", "Sex": "Male", "Freq": 7 }, { "Hair": "HairBlond", "Eye": "EyeGreen", "Sex": "Male", "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] })
}
chart
.showControls(false)
d3.select("#" + opts.id)
.append('svg')
.datum(data)
.transition().duration(500)
.call(chart);
nv.utils.windowResize(chart.update);
return chart;
});
};
<script></script>