-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
182 lines (159 loc) · 7.65 KB
/
index.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<!DOCTYPE html>
<head>
<meta charset="utf-8" />
<link
rel="stylesheet"
type="text/css"
href="https://unpkg.com/dc@4/dist/style/dc.css"
/>
<script src="https://unpkg.com/d3@5/dist/d3.js"></script>
<script src="https://unpkg.com/[email protected]/crossfilter.js"></script>
<script src="https://unpkg.com/dc@4/dist/dc.js"></script>
<script src="https://rawgit.com/crossfilter/reductio/master/reductio.js"></script>
<script src="https://npmcdn.com/universe@latest/universe.js"></script>
<style>
.x-axis-label {
font-size:xx-small;
}
.flex-container {
height: 100%;
width: 100%;
padding: 0;
margin: 0;
display: flex;
flex-wrap: wrap;
align-content: flex-start;
justify-content: center;
}
.flex-item {
float: left;
}
.dc-chart g.row text {fill: black;}
</style>
</head>
<body>
<div class="flex-container">
<div class="flex-item" >
<div class="dc-data-count">
<div><strong>DfT Road Safety Data</strong></div>
<span>
<span class="filter-count"></span>
selected out of
<span class="total-count"></span>
records |
<a href="javascript:dc.filterAll(); dc.renderAll(); addChartText();">Reset All</a>
</span>
<div><a href="https://github.com/awjreynolds/awjreynolds.github.io">Github Repo</a>
<a href="https://data.gov.uk/dataset/cb7ae6f0-4be6-4935-9277-47e5ce24a11f/road-safety-data">DfT Data Here</a></div>
<strong>After charts appear click on a chart row!</strong>
</div>
<div id="sPolice_Force"><div>police_force</div></div>
<div id="sLocal_authority_district"><div>local_authority_district</div></div>
<div id="sLocal_authority_highway"><div>local_authority_highway</div></div>
</div>
<div class="flex-item" id="Chart_Accident_Severity"></div>
<div class="flex-item" id="Chart_Police_Force"></div>
<div class="flex-item" id="Chart_Local_Authority_District"></div>
<div class="flex-item" id="Chart_Local_Authority_Highway"></div>
<div class="flex-item" id="Chart_Number_of_Vehicles"></div>
<div class="flex-item" id="Chart_Number_of_Casualties"></div>
<div class="flex-item" id="Chart_year"></div>
<div class="flex-item" id="Chart_month"></div>
<div class="flex-item" id="Chart_Day_of_Week"></div>
<div class="flex-item" id="Chart_hour"></div>
<div class="flex-item" id="Chart_vehicle_type"></div>
<div class="flex-item" id="Chart_vehicle_manoeuvre"></div>
<div class="flex-item" id="Chart_1st_Road_Class"></div>
<div class="flex-item" id="Chart_Road_Type"></div>
<div class="flex-item" id="Chart_Speed_limit"></div>
<div class="flex-item" id="Chart_Junction_Detail"></div>
<div class="flex-item" id="Chart_Junction_Control"></div>
<div class="flex-item" id="Chart_2nd_Road_Class"></div>
<div class="flex-item" id="Chart_Pedestrian_Crossing-Human_Control"></div>
<div class="flex-item" id="Chart_Pedestrian_Crossing-Physical_Facilities"></div>
<div class="flex-item" id="Chart_Light_Conditions"></div>
<div class="flex-item" id="Chart_Weather_Conditions"></div>
<div class="flex-item" id="Chart_Road_Surface_Conditions"></div>
<div class="flex-item" id="Chart_Special_Conditions_at_Site"></div>
<div class="flex-item" id="Chart_Carriageway_Hazards"></div>
<div class="flex-item" id="Chart_Urban_or_Rural_Area"></div>
<div class="flex-item" id="Chart_Did_Police_Officer_Attend_Scene_of_Accident"></div>
<div class="flex-item" id="Chart_Casualty_Class"></div>
<div class="flex-item" id="Chart_Sex_of_Casualty"></div>
<div class="flex-item" id="Chart_Age_Band_of_Casualty"></div>
<div class="flex-item" id="Chart_Casualty_Severity"></div>
<div class="flex-item" id="Chart_Pedestrian_Location"></div>
<div class="flex-item" id="Chart_Pedestrian_Movement"></div>
<div class="flex-item" id="Chart_Car_Passenger"></div>
<div class="flex-item" id="Chart_Bus_or_Coach_Passenger"></div>
<div class="flex-item" id="Chart_Pedestrian_Road_Maintenance_Worker"></div>
<div class="flex-item" id="Chart_Casualty_Type"></div>
<div class="flex-item" id="Chart_Casualty_Home_Area_Type"></div>
<div class="flex-item" id="Chart_Casualty_IMD_Decile"></div>
<div class="flex-item" id="Chart_Vehicle_Type"></div>
<div class="flex-item" id="Chart_Towing_and_Articulation"></div>
<div class="flex-item" id="Chart_Vehicle_Manoeuvre"></div>
<div class="flex-item" id="Chart_Vehicle_Location-Restricted_Lane"></div>
<div class="flex-item" id="Chart_Junction_Location"></div>
<div class="flex-item" id="Chart_Skidding_and_Overturning"></div>
<div class="flex-item" id="Chart_Vehicle_Leaving_Carriageway"></div>
<div class="flex-item" id="Chart_Hit_Object_off_Carriageway"></div>
<div class="flex-item" id="Chart_1st_Point_of_Impact"></div>
<div class="flex-item" id="Chart_Was_Vehicle_Left_Hand_Drive"></div>
<div class="flex-item" id="Chart_Journey_Purpose_of_Driver"></div>
<div class="flex-item" id="Chart_Sex_of_Driver"></div>
<div class="flex-item" id="Chart_Age_Band_of_Driver"></div>
<div class="flex-item" id="Chart_Propulsion_Code"></div>
<div class="flex-item" id="Chart_Driver_IMD_Decile"></div>
<div class="flex-item" id="Chart_Driver_Home_Area_Type"></div>
<div class="flex-item" id="Chart_Vehicle_IMD_Decile"></div>
<!-- big! -->
<div class="flex-item" id="Chart_Engine_Capacity_CC"></div>
<!-- <div class="flex-item" id="towing_and_articulation"></div>
<div class="flex-item" id="vehicle_location_restricted_lane"></div>
<div class="flex-item" id="junction_location"></div>
<div class="flex-item" id="skidding_and_overturning"></div>
<div class="flex-item" id="hit_object_in_carriageway"></div>
<div class="flex-item" id="vehicle_leaving_carriageway"></div>
<div class="flex-item" id="hit_object_off_carriageway"></div>
<div class="flex-item" id="first_point_of_impact"></div>
<div class="flex-item" id="was_vehicle_left_hand_drive"></div>
<div class="flex-item" id="journey_purpose_of_driver"></div>
<div class="flex-item" id="sex_of_driver"></div>
<div class="flex-item" id="age_band_of_driver"></div>
<div class="flex-item" id="propulsion_code"></div>
<div class="flex-item" id="driver_home_area_type"></div> -->
<!-- <div class="flex-item" id="engine_capacity_cc"></div>
<div class="flex-item" id="age_of_driver"></div>
<div class="flex-item" id="age_of_vehicle"></div> -->
</div>
<!-- Script must run *after* set up of divs. -->
<script type="text/javascript" src="stats19lookup.js"></script>
<script type="text/javascript" src="stats19.js"></script>
<!-- <script>
var chart = dc.barChart("#test");
d3.csv("single_car_pedestrian_collisions_2013-2018.csv").then(function(stats19) {
stats19.forEach(function(x) {
x.engine_capacity_cc = +x.engine_capacity_cc;
});
var ndx = crossfilter(stats19),
engineCcDimension = ndx.dimension(function(d) {return +d.engine_capacity_cc}),
engineCcSumGroup = engineCcDimension.group().reduceSum(function(d) {return +d.engine_capacity_cc}),
chart
.width(768)
.height(480)
.x(d3.scaleLinear().domain([1,7000]))
.brushOn(false)
.yAxisLabel("Total")
.xAxisLabel("Engine Size")
.dimension(engineCcDimension)
.group(engineCcSumGroup)
.on('renderlet', function(chart) {
chart.selectAll('rect').on("click", function(d) {
console.log("click!", d);
});
});
chart.render();
});
</script> -->
</body>