Skip to content

Instantly share code, notes, and snippets.

@AnotherContext
Created September 28, 2014 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AnotherContext/ef2a479ad16391e24416 to your computer and use it in GitHub Desktop.
Save AnotherContext/ef2a479ad16391e24416 to your computer and use it in GitHub Desktop.
DA: calls4assistance and crimes vs areas heatmap
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<link rel='stylesheet' href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
<script src='http://ramnathv.github.io/rCharts/libraries/widgets/polycharts/js/polychart2.standalone.js' type='text/javascript'></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js"></script>
<style>
.rChart {
display: block
margin: auto auto;
width: 100%;
height: 400px;
}
.bs-docs-example:after {
content: "";
background: transparent;
border: none;
}
</style>
</head>
<body ng-app>
<div class='container' ng-controller="DemoCtrl" ng-init="drawChart()">
<div class='row'>
<div class='col-md-3'>
<form class='well'>
<label><b>Select Region :</b></label>
<select class='form-control' ng-model="opts.Region.var"
ng-options="ctl for ctl in controls.Region.values">
</select><br>
</form>
</div>
<div class='col-md-9'>
<div class="bs-docs-example">
<div id='chartc94787535a7' class='rChart '>
<svg></svg>
</div>
</div>
</div>
</div>
</div>
<script type='text/javascript'>
function DemoCtrl($scope){
$scope.chartParams = {
"dom": "chartc94787535a7",
"width": 700,
"height": 600,
"layers": [
{
"x": "Calls",
"y": "Area",
"data": {
"Area": [ "Avon & Somerset", "Bedfordshire", "Cambridgeshire", "Cheshire", "Cleveland", "Cumbria", "Derbyshire", "Devon & Cornwall", "Dorset", "Durham", "Dyfed-Powys", "Essex", "Gloucestershire", "Greater Manchester", "Gwent", "Hampshire", "Hertfordshire", "Humberside", "Kent", "Lancashire", "Leicestershire", "Lincolnshire", "Metropolitan Police", "Merseyside", "Norfolk", "North Wales", "North Yorkshire", "Northamptonshire", "Northumbria", "Nottinghamshire", "South Wales", "South Yorkshire", "Staffordshire", "Suffolk", "Surrey", "Sussex", "Thames Valley", "Warwickshire", "West Mercia", "West Midlands", "West Yorkshire", "Wiltshire", "City of London", "Avon & Somerset", "Bedfordshire", "Cambridgeshire", "Cheshire", "Cleveland", "Cumbria", "Derbyshire", "Devon & Cornwall", "Dorset", "Durham", "Dyfed-Powys", "Essex", "Gloucestershire", "Greater Manchester", "Gwent", "Hampshire", "Hertfordshire", "Humberside", "Kent", "Lancashire", "Leicestershire", "Lincolnshire", "Metropolitan Police", "Merseyside", "Norfolk", "North Wales", "North Yorkshire", "Northamptonshire", "Northumbria", "Nottinghamshire", "South Wales", "South Yorkshire", "Staffordshire", "Suffolk", "Surrey", "Sussex", "Thames Valley", "Warwickshire", "West Mercia", "West Midlands", "West Yorkshire", "Wiltshire", "City of London" ],
"Region": [ "South West Region", "East of England Region", "East of England Region", "North West Region", "North East Region", "North West Region", "Yorkshire and the Humber Region", "South West Region", "South West Region", "North East Region", "Wales", "East of England Region", "South West Region", "North West Region", "Wales", "South East Region", "East of England Region", "Yorkshire and the Humber Region", "South East Region", "North West Region", "East Midlands Region", "East Midlands Region", "London Region", "North West Region", "London Region", "East of England Region", "Wales", "Yorkshire and the Humber Region", "East Midlands Region", "North East Region", "East Midlands Region", "Wales", "Yorkshire and the Humber Region", "West Midlands Region", "East of England Region", "South East Region", "South East Region", "South East Region", "West Midlands Region", "West Midlands Region", "West Midlands Region", "Yorkshire and the Humber Region", "South West Region", "South West Region", "East of England Region", "East of England Region", "North West Region", "North East Region", "North West Region", "Yorkshire and the Humber Region", "South West Region", "South West Region", "North East Region", "Wales", "East of England Region", "South West Region", "North West Region", "Wales", "South East Region", "East of England Region", "Yorkshire and the Humber Region", "South East Region", "North West Region", "East Midlands Region", "East Midlands Region", "London Region", "North West Region", "London Region", "East of England Region", "Wales", "Yorkshire and the Humber Region", "East Midlands Region", "North East Region", "East Midlands Region", "Wales", "Yorkshire and the Humber Region", "West Midlands Region", "East of England Region", "South East Region", "South East Region", "South East Region", "West Midlands Region", "West Midlands Region", "West Midlands Region", "Yorkshire and the Humber Region", "South West Region" ],
"Calls": [ "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "calls.for.assistance.with.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker", "crime.with.a.DA.marker" ],
"Value": [ 18780, 9453, 11200, 3733, 12659, 6748, 18220, 27871, 8381, 14057, 2456, 27850, 5092, 65435, 12832, 29942, 12149, 19344, 22187, 37206, 17804, 10055, 210377, 30135, 16239, 10475, 10046, 12855, 29479, 31296, 22246, 21437, 14936, 4962, 11072, 24537, 36525, 7091, 17423, 62646, 38092, 4996, 158, 7877, 2868, 2927, 4779, 3168, 2308, 5054, 9212, 2648, 2280, 1346, 8862, 1904, 13399, 3828, 8068, 3737, 4014, 9010, 8841, 5429, 2726, 50263, 4817, 3277, 3922, 2648, 3685, 4871, 7156, 6370, 5278, 5844, 2861, 4339, 7018, 9728, 1281, 4859, 13715, 10690, 2720, 71 ],
"Rescale": [ 0.088584, 0.044216, 0.052526, 0.017006, 0.059467, 0.031348, 0.08592, 0.13183, 0.039116, 0.066117, 0.010931, 0.13173, 0.023471, 0.31052, 0.06029, 0.14168, 0.057041, 0.091267, 0.10479, 0.17624, 0.083941, 0.047079, 1, 0.1426, 0.076496, 0.049077, 0.047037, 0.060399, 0.13948, 0.14812, 0.10507, 0.10122, 0.070298, 0.022852, 0.051917, 0.11597, 0.173, 0.03298, 0.082129, 0.29725, 0.18045, 0.023014, 0, 0.15552, 0.055726, 0.056901, 0.0938, 0.061703, 0.044569, 0.099279, 0.18212, 0.051343, 0.044011, 0.025402, 0.17515, 0.03652, 0.26554, 0.074853, 0.15933, 0.07304, 0.078558, 0.1781, 0.17473, 0.10675, 0.052897, 1, 0.094557, 0.063875, 0.076725, 0.051343, 0.072004, 0.095633, 0.14116, 0.1255, 0.10374, 0.11502, 0.055587, 0.085033, 0.13841, 0.1924, 0.024107, 0.095394, 0.27184, 0.21157, 0.052777, 0 ]
},
"facet": null,
"color": "Rescale",
"type": "tile"
}
],
"facet": [],
"guides": {
"reduceXTicks": false,
"color": {
"scale": {
"type": "gradient",
"lower": "white",
"upper": "green"
}
},
"y": {
"numticks": 43
}
},
"coord": [],
"id": "chartc94787535a7"
}
_.each($scope.chartParams.layers, function(el){
el.data = polyjs.data(el.data)
})
$scope.controls = {
"Region": {
"name": "Region",
"value": "Wales",
"values": [ "South West Region", "East of England Region", "East of England Region", "North West Region", "North East Region", "North West Region", "Yorkshire and the Humber Region", "South West Region", "South West Region", "North East Region", "Wales", "East of England Region", "South West Region", "North West Region", "Wales", "South East Region", "East of England Region", "Yorkshire and the Humber Region", "South East Region", "North West Region", "East Midlands Region", "East Midlands Region", "London Region", "North West Region", "London Region", "East of England Region", "Wales", "Yorkshire and the Humber Region", "East Midlands Region", "North East Region", "East Midlands Region", "Wales", "Yorkshire and the Humber Region", "West Midlands Region", "East of England Region", "South East Region", "South East Region", "South East Region", "West Midlands Region", "West Midlands Region", "West Midlands Region", "Yorkshire and the Humber Region", "South West Region", "South West Region", "East of England Region", "East of England Region", "North West Region", "North East Region", "North West Region", "Yorkshire and the Humber Region", "South West Region", "South West Region", "North East Region", "Wales", "East of England Region", "South West Region", "North West Region", "Wales", "South East Region", "East of England Region", "Yorkshire and the Humber Region", "South East Region", "North West Region", "East Midlands Region", "East Midlands Region", "London Region", "North West Region", "London Region", "East of England Region", "Wales", "Yorkshire and the Humber Region", "East Midlands Region", "North East Region", "East Midlands Region", "Wales", "Yorkshire and the Humber Region", "West Midlands Region", "East of England Region", "South East Region", "South East Region", "South East Region", "West Midlands Region", "West Midlands Region", "West Midlands Region", "Yorkshire and the Humber Region", "South West Region" ],
"label": "Select Region :"
}
}
$scope.opts = $scope.chartParams.layers[0];
$scope.drawChart = function(){
$scope.chart = polyjs.chart($scope.chartParams)
}
$scope.updateChart = function(){
$scope.chart.make($scope.chartParams)
}
$scope.$watch('opts', function(){
$scope.chartParams.layers[0] = $scope.opts;
$scope.updateChart();
}, true)
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment