-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdifferent_crimes.json
152 lines (145 loc) · 4.54 KB
/
different_crimes.json
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
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"config": {
"style": {
"cell": {
"stroke": "transparent"
}
}
},
"data": {
"url": "https://raw.githubusercontent.com/nkan0016/FIT3179-DV2/main/data/crime_and_incarceration_by_state.csv"
},
"params": [
{
"name": "state_selection",
"bind": {
"input": "select",
"options": [
null,
"CALIFORNIA",
"FLORIDA",
"NEW YORK",
"TEXAS"
],
"labels": [
"All",
"California",
"Florida",
"New York",
"Texas"
],
"name": "State Selection: "
}
}
],
"transform": [
{"filter": "datum.jurisdiction == 'CALIFORNIA' || datum.jurisdiction == 'TEXAS' || datum.jurisdiction == 'FLORIDA' || datum.jurisdiction == 'NEW YORK'"},
{"calculate": "datum.prisoner_count/datum.state_population * 10000", "as": "Total Prisoners"},
{"calculate": "datum.robbery/datum.state_population * 10000", "as": "Robberies"},
{"calculate": "datum.agg_assault/datum.state_population * 10000", "as": "Assaults"},
{"calculate": "datum.burglary/datum.state_population * 10000", "as": "Burglaries"},
{"calculate": "datum.vehicle_theft/datum.state_population * 10000", "as": "Vehicle Thefts"},
{"fold": ["Robberies", "Assaults", "Burglaries", "Vehicle Thefts"]}
],
"vconcat": [
{
"width": 552,
"height": 300,
"title": "Prison Rate per 10,000 People Over Time in USA",
"layer": [
{
"mark": {"type": "line", "point": true},
"encoding": {
"x": {
"field": "year",
"type": "temporal",
"timeUnit": "year",
"axis": {"title": "Year", "tickCount": 10, "grid": false}
},
"y": {
"field": "Total Prisoners",
"type": "quantitative",
"title": "Rate per 10,000 People"
},
"color": {
"field": "jurisdiction",
"type": "nominal",
"title": "Crime",
"legend": null
},
"tooltip": [
{"field": "jurisdiction", "type": "nominal", "title": "State"},
{"field": "year", "type": "temporal", "title": "Year", "timeUnit": "year"},
{"field": "Total Prisoners", "type": "quantitative", "title": "Rate per 10,000", "format": ".1f"},
{"field": "prisoner_count", "type": "quantitative", "title": "Total Prisoners", "format": ","}
],
"opacity": {
"condition": {"test": "state_selection == null || datum.jurisdiction == state_selection", "value": 1},
"value": 0.1
}
}
},
{
"data": {"values": [{}]},
"mark": {"type": "rule", "strokeDash": [2, 2], "size": 2},
"encoding": {"x": {"datum": {"year": 2008}}}
},
{
"data": {
"values": [{
"x": 1202999999991,
"y": 10
}]
},
"mark": {"type": "text",
"align": "left",
"fontSize": 13,
"fontWeight": "bold"
},
"encoding": {
"text": {"value": ["2008 had the highest total prison", "population in America!"]},
"x": {"field": "x", "type": "temporal"},
"y": {"field": "y", "type": "quantitative"}
}
}
]
},
{
"width": 552,
"height": 200,
"title": "Reported Crimes by Crime Type in 2016",
"transform": [
{"filter": "state_selection == null || datum.jurisdiction == state_selection"},
{"filter": "datum.year == 1451606400000"}
],
"mark": "bar",
"encoding": {
"x": {
"field": "value",
"type": "quantitative",
"title": "Crimes per 10,000"
},
"y": {
"field": "key",
"type": "nominal",
"title": "Type of Crime",
"axis": {
"labelAngle": 0
}
},
"color": {
"field": "jurisdiction",
"type": "nominal",
"title": "Crime",
"legend": null,
"scale": {"range": ["#800e10","#0288f5","#bd8400","#c51b8a"]}
},
"tooltip": [
{"field": "jurisdiction", "type": "nominal", "title": "State"},
{"field": "value", "type": "quantitative", "title": "Rate per 10,000", "format": ".1f"}
]
}
}
]
}