Created
September 28, 2014 15:54
-
-
Save AnotherContext/6657274551e37889beb1 to your computer and use it in GitHub Desktop.
Domestic abuse: assault by region comparison
This file contains 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: 400px; | |
} | |
</style> | |
</head> | |
<body > | |
<div id = 'chartc9439ea1a94' class = 'rChart nvd3'></div> | |
<script type='text/javascript'> | |
$(document).ready(function(){ | |
drawchartc9439ea1a94() | |
}); | |
function drawchartc9439ea1a94(){ | |
var opts = { | |
"dom": "chartc9439ea1a94", | |
"width": 800, | |
"height": 400, | |
"x": "Region.Name", | |
"y": "value", | |
"group": "variable", | |
"type": "multiBarChart", | |
"id": "chartc9439ea1a94" | |
}, | |
data = [ | |
{ | |
"Area.Name": 107, | |
"Region.Name": "East Midlands Region", | |
"variable": "assault.with.intent.to.cause.serious.harm.DA.marker", | |
"value": 330 | |
}, | |
{ | |
"Area.Name": 99, | |
"Region.Name": "East of England Region", | |
"variable": "assault.with.intent.to.cause.serious.harm.DA.marker", | |
"value": 228 | |
}, | |
{ | |
"Area.Name": 51, | |
"Region.Name": "London Region", | |
"variable": "assault.with.intent.to.cause.serious.harm.DA.marker", | |
"value": 2535 | |
}, | |
{ | |
"Area.Name": 48, | |
"Region.Name": "North East Region", | |
"variable": "assault.with.intent.to.cause.serious.harm.DA.marker", | |
"value": 148 | |
}, | |
{ | |
"Area.Name": 71, | |
"Region.Name": "North West Region", | |
"variable": "assault.with.intent.to.cause.serious.harm.DA.marker", | |
"value": 549 | |
}, | |
{ | |
"Area.Name": 151, | |
"Region.Name": "South East Region", | |
"variable": "assault.with.intent.to.cause.serious.harm.DA.marker", | |
"value": 231 | |
}, | |
{ | |
"Area.Name": 39, | |
"Region.Name": "South West Region", | |
"variable": "assault.with.intent.to.cause.serious.harm.DA.marker", | |
"value": 263 | |
}, | |
{ | |
"Area.Name": 89, | |
"Region.Name": "Wales", | |
"variable": "assault.with.intent.to.cause.serious.harm.DA.marker", | |
"value": 216 | |
}, | |
{ | |
"Area.Name": 158, | |
"Region.Name": "West Midlands Region", | |
"variable": "assault.with.intent.to.cause.serious.harm.DA.marker", | |
"value": 406 | |
}, | |
{ | |
"Area.Name": 133, | |
"Region.Name": "Yorkshire and the Humber Region", | |
"variable": "assault.with.intent.to.cause.serious.harm.DA.marker", | |
"value": 210 | |
}, | |
{ | |
"Area.Name": 107, | |
"Region.Name": "East Midlands Region", | |
"variable": "Assault.with.injury.DA.marker", | |
"value": 7180 | |
}, | |
{ | |
"Area.Name": 99, | |
"Region.Name": "East of England Region", | |
"variable": "Assault.with.injury.DA.marker", | |
"value": 8910 | |
}, | |
{ | |
"Area.Name": 51, | |
"Region.Name": "London Region", | |
"variable": "Assault.with.injury.DA.marker", | |
"value": 17115 | |
}, | |
{ | |
"Area.Name": 48, | |
"Region.Name": "North East Region", | |
"variable": "Assault.with.injury.DA.marker", | |
"value": 4725 | |
}, | |
{ | |
"Area.Name": 71, | |
"Region.Name": "North West Region", | |
"variable": "Assault.with.injury.DA.marker", | |
"value": 11742 | |
}, | |
{ | |
"Area.Name": 151, | |
"Region.Name": "South East Region", | |
"variable": "Assault.with.injury.DA.marker", | |
"value": 12507 | |
}, | |
{ | |
"Area.Name": 39, | |
"Region.Name": "South West Region", | |
"variable": "Assault.with.injury.DA.marker", | |
"value": 8371 | |
}, | |
{ | |
"Area.Name": 89, | |
"Region.Name": "Wales", | |
"variable": "Assault.with.injury.DA.marker", | |
"value": 5221 | |
}, | |
{ | |
"Area.Name": 158, | |
"Region.Name": "West Midlands Region", | |
"variable": "Assault.with.injury.DA.marker", | |
"value": 12175 | |
}, | |
{ | |
"Area.Name": 133, | |
"Region.Name": "Yorkshire and the Humber Region", | |
"variable": "Assault.with.injury.DA.marker", | |
"value": 8079 | |
}, | |
{ | |
"Area.Name": 107, | |
"Region.Name": "East Midlands Region", | |
"variable": "harassment.DA.marker", | |
"value": 1786 | |
}, | |
{ | |
"Area.Name": 99, | |
"Region.Name": "East of England Region", | |
"variable": "harassment.DA.marker", | |
"value": 2771 | |
}, | |
{ | |
"Area.Name": 51, | |
"Region.Name": "London Region", | |
"variable": "harassment.DA.marker", | |
"value": 7794 | |
}, | |
{ | |
"Area.Name": 48, | |
"Region.Name": "North East Region", | |
"variable": "harassment.DA.marker", | |
"value": 826 | |
}, | |
{ | |
"Area.Name": 71, | |
"Region.Name": "North West Region", | |
"variable": "harassment.DA.marker", | |
"value": 3417 | |
}, | |
{ | |
"Area.Name": 151, | |
"Region.Name": "South East Region", | |
"variable": "harassment.DA.marker", | |
"value": 2658 | |
}, | |
{ | |
"Area.Name": 39, | |
"Region.Name": "South West Region", | |
"variable": "harassment.DA.marker", | |
"value": 1482 | |
}, | |
{ | |
"Area.Name": 89, | |
"Region.Name": "Wales", | |
"variable": "harassment.DA.marker", | |
"value": 1127 | |
}, | |
{ | |
"Area.Name": 158, | |
"Region.Name": "West Midlands Region", | |
"variable": "harassment.DA.marker", | |
"value": 3549 | |
}, | |
{ | |
"Area.Name": 133, | |
"Region.Name": "Yorkshire and the Humber Region", | |
"variable": "harassment.DA.marker", | |
"value": 1853 | |
}, | |
{ | |
"Area.Name": 107, | |
"Region.Name": "East Midlands Region", | |
"variable": "sexual.offences.DA.marker", | |
"value": 404 | |
}, | |
{ | |
"Area.Name": 99, | |
"Region.Name": "East of England Region", | |
"variable": "sexual.offences.DA.marker", | |
"value": 621 | |
}, | |
{ | |
"Area.Name": 51, | |
"Region.Name": "London Region", | |
"variable": "sexual.offences.DA.marker", | |
"value": 1229 | |
}, | |
{ | |
"Area.Name": 48, | |
"Region.Name": "North East Region", | |
"variable": "sexual.offences.DA.marker", | |
"value": 174 | |
}, | |
{ | |
"Area.Name": 71, | |
"Region.Name": "North West Region", | |
"variable": "sexual.offences.DA.marker", | |
"value": 849 | |
}, | |
{ | |
"Area.Name": 151, | |
"Region.Name": "South East Region", | |
"variable": "sexual.offences.DA.marker", | |
"value": 881 | |
}, | |
{ | |
"Area.Name": 39, | |
"Region.Name": "South West Region", | |
"variable": "sexual.offences.DA.marker", | |
"value": 746 | |
}, | |
{ | |
"Area.Name": 89, | |
"Region.Name": "Wales", | |
"variable": "sexual.offences.DA.marker", | |
"value": 338 | |
}, | |
{ | |
"Area.Name": 158, | |
"Region.Name": "West Midlands Region", | |
"variable": "sexual.offences.DA.marker", | |
"value": 633 | |
}, | |
{ | |
"Area.Name": 133, | |
"Region.Name": "Yorkshire and the Humber Region", | |
"variable": "sexual.offences.DA.marker", | |
"value": 531 | |
} | |
] | |
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