-
Notifications
You must be signed in to change notification settings - Fork 1
/
districtcrime.html
97 lines (87 loc) · 3.83 KB
/
districtcrime.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!DOCTYPE html>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="js/d3.v3.min.js"></script>
<script src="js/crossfilter.min.js"></script>
<script src="js/dc.min.js"></script>
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/dc.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/style (2).css">
<link href="css/font-awesome.min.css" rel="stylesheet">
<link href="css/main.css" rel="stylesheet">
<title>Districtwise IPC Crime in 2013</title>
<body>
<nav class="menu" id="theMenu">
<div class="menu-wrap">
<h1 class="logo"><a href="index.html#home">HOME</a></h1>
<i class="fa fa-arrow-right menu-close"></i>
<a href="index.html">Home</a>
<a href="dc.html">GSDP of State</a>
<a href="gvis.html">Google Visualisation</a>
<a href="stateinvest.html">Statewise Investment Proposal</a>
<a href="sectorinvest.html">Sectorwise Investment Proposal</a>
<a href="homeasset.html">2013 Census Home Asset</a>
<a href="districtcrime.html">Districtwise IPC crimes in 2013</a>
<a href="statecrop.html">Statewise Crop Production</a>
<a href="kaggletitanic.html">Kaggle Titanic Data</a>
<a href="#contact">Contact</a>
<a href="#"><i class="fa fa-facebook"></i></a>
<a href="#"><i class="fa fa-twitter"></i></a>
<a href="#"><i class="fa fa-dribbble"></i></a>
<a href="#"><i class="fa fa-envelope"></i></a>
</div>
<!-- Menu button -->
<div id="menuToggle"><i class="fa fa-bars"></i></div>
</nav>
<div class="container-fluid">
<div class="row-fluid">
<div class="col-md-6" id="choro"></div>
<div class="col-md-6" id="bar"></div>
</div>
<script>
var parseDate = d3.time.format("%Y").parse;
d3.csv("data/districtcrimemelt.csv", function(csv) {
var data = crossfilter(csv);
var district = data.dimension(function(d){return d.District;});
var distsum = district.group().reduceSum(function(d) {return d.value;});
var crime = data.dimension(function(d){return d.crime;});
var crimesum = crime.group().reduceSum(function(d) {return d.value;});
var choro = dc.geoChoroplethChart('#choro');
var bar = dc.rowChart('#bar');
var proj = d3.geo.mercator().scale(900).center([95,25]);
d3.json("dist-geo (1).json", function(dist){
choro.width(700)
.height(600)
.dimension(district)
.group(distsum)
.projection(proj)
.colors(d3.scale.quantize().range(["#E2F2FF", "#C4E4FF", "#9ED2FF", "#6BBAFF", "#36A2FF", "#1E96FF", "#0089FF", "#0061B5"]))
//.colorDomain([100, 8000])
.colorCalculator(function (d) { return d ? choro.colors()(d) : '#ccc'; })
.overlayGeoJson(dist.features, "district", function (d) {
return d.properties.DISTRICT;
});
choro.on("preRender", function(chart) {
chart.colorDomain(d3.extent(chart.data(), chart.valueAccessor()));
});
choro.on("preRedraw", function(chart) {
chart.colorDomain(d3.extent(chart.data(), chart.valueAccessor()));
});
//bar.xUnits(function(){return 18;}); //manually setting bar width
bar
.margins({top: 25, left: 60, right: 10, bottom: 20})
.width(500).height(550)
.dimension(crime)
.group(crimesum)
.colors('purple')
.elasticX(true);
dc.renderAll();
});
});
</script>
<script src="js/main.js"></script>
</body>
</html>