Final commit, added presentation script
This commit is contained in:
BIN
SEN presentation.pdf
Normal file
BIN
SEN presentation.pdf
Normal file
Binary file not shown.
BIN
data.sqlite3
BIN
data.sqlite3
Binary file not shown.
@@ -31,7 +31,7 @@ cur.execute("PRAGMA foreign_keys = ON;")
|
||||
categories = """CREATE TABLE IF NOT EXISTS categories(id INTEGER PRIMARY KEY AUTOINCREMENT , name TEXT)"""
|
||||
subcat = """CREATE TABLE IF NOT EXISTS subcat(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, cat_id INTEGER, FOREIGN KEY(cat_id) REFERENCES categories(id))"""
|
||||
location = """CREATE TABLE IF NOT EXISTS location(id INTEGER PRIMARY KEY AUTOINCREMENT , subdiv TEXT, LGA TEXT)"""
|
||||
stat = """CREATE TABLE IF NOT EXISTS statistics(id INTEGER PRIMARY KEY AUTOINCREMENT , category_id INTEGER, subcat_id INTEGER DEFAULT 0, location_id INTEGER, month TEXT NOT NULL, count TEXT NOT NULL,FOREIGN KEY(category_id) REFERENCES categories(id), FOREIGN KEY(subcat_id) REFERENCES subcat(id), FOREIGN KEY(location_id) REFERENCES location(id))"""
|
||||
stat = """CREATE TABLE IF NOT EXISTS statistics(id INTEGER PRIMARY KEY AUTOINCREMENT , category_id INTEGER, subcat_id INTEGER DEFAULT 0, location_id INTEGER, count TEXT NOT NULL,FOREIGN KEY(category_id) REFERENCES categories(id), FOREIGN KEY(subcat_id) REFERENCES subcat(id), FOREIGN KEY(location_id) REFERENCES location(id))"""
|
||||
cur.execute(categories)
|
||||
conn.commit()
|
||||
cur.execute(subcat)
|
||||
@@ -44,7 +44,7 @@ conn.commit()
|
||||
categories_ins = """INSERT INTO categories VALUES(NULL, :category)"""
|
||||
subcat_ins = """INSERT INTO subcat VALUES(NULL, :name, :catid)"""
|
||||
location_ins = """INSERT INTO location VALUES(NULL, :subdiv, :lga)"""
|
||||
stat_ins = """INSERT INTO statistics VALUES(NULL,:cat_id,:subcat_id,:loc_id,:mnth,:cnt)"""
|
||||
stat_ins = """INSERT INTO statistics VALUES(NULL,:cat_id,:subcat_id,:loc_id,:cnt)"""
|
||||
|
||||
for i in range(len(cat)):
|
||||
cur.execute(categories_ins, {"category": cat[i]})
|
||||
@@ -79,7 +79,7 @@ for i in range(len(biglst)):
|
||||
dat_lst.append(biglst[i][j])
|
||||
|
||||
|
||||
init_lst.append({"cat_id": catid, "subcat_id": subcatid, "loc_id": locid, "mnth": pandas.to_datetime(str(init_date+numpy.timedelta64(j-4, 'M'))).strftime('%Y.%m'),"cnt":json.dumps(dat_lst)})
|
||||
init_lst.append({"cat_id": catid, "subcat_id": subcatid, "loc_id": locid,"cnt":json.dumps(dat_lst)})
|
||||
print(i)
|
||||
cur.executemany(stat_ins, init_lst)
|
||||
conn.commit()
|
||||
|
||||
14
index.html
14
index.html
@@ -1,21 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Crime Statistics</title>
|
||||
<title>NSW Crime Statistics</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<!-- dependencies -->
|
||||
<!-- Bootstrap -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/@coreui/coreui@5.2.0/dist/css/themes/bootstrap/bootstrap.min.css" rel="stylesheet" integrity="sha384-nQQlHXZO4YmST3YDqk/JU3f1t2D58a/nPd1QbiLecouKn68glzRym4BlOxlr5Rrg" crossorigin="anonymous">
|
||||
</head>
|
||||
<body style="background-color: #ffffff;">
|
||||
<!--Bootstrap-->
|
||||
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.min.js" integrity="sha384-0pUGZvbkm6XF6gxjEnlmuGrJXVbNuzT9qBBavbLwCsOGabYfZo0T0to5eqruptLy" crossorigin="anonymous"></script>
|
||||
<!--chartjs-->
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
<!--handlebars-->
|
||||
<script src="https://cdn.jsdelivr.net/npm/handlebars@latest/dist/handlebars.js"></script>
|
||||
<!-- bootstrap--> <!-- SQL -->
|
||||
<!--sqlite-->
|
||||
<script src="https://12sen.dchen4.au/sqlite-js/sqlite3.js"></script>
|
||||
<!--moment-->
|
||||
<script src="https://cdn.jsdelivr.net/npm/moment@2.30.1/moment.min.js"></script>
|
||||
|
||||
|
||||
@@ -178,13 +180,13 @@
|
||||
|
||||
<ul class="nav nav-tabs" id="myTab" role="tablist">
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link active" id="home-tab" data-bs-toggle="tab" data-bs-target="#home" type="button" role="tab" aria-controls="home" aria-selected="true">Line</button>
|
||||
<button class="nav-link active" id="home-tab" data-bs-toggle="tab" data-bs-target="#home" type="button" role="tab" aria-controls="Line" aria-selected="true">Line</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#profile" type="button" role="tab" aria-controls="profile" aria-selected="false">Pie/Bar</button>
|
||||
<button class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#profile" type="button" role="tab" aria-controls="Pie/Bar" aria-selected="false">Pie/Bar</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link" id="contact-tab" data-bs-toggle="tab" data-bs-target="#contact" type="button" role="tab" aria-controls="contact" aria-selected="false">Table</button>
|
||||
<button class="nav-link" id="contact-tab" data-bs-toggle="tab" data-bs-target="#contact" type="button" role="tab" aria-controls="Table" aria-selected="false">Table</button>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content" id="myTabContent">
|
||||
|
||||
12
index.js
12
index.js
@@ -362,10 +362,10 @@ class FilterQueue{
|
||||
//all array
|
||||
for (var i=start_cnt;i<end_cnt;i++){
|
||||
var val;
|
||||
val = JSON.parse(res[0][5])[i]
|
||||
val = JSON.parse(res[0][4])[i]
|
||||
//one array, find avg of all 1st val
|
||||
for (var j=1;j<res.length;j++){
|
||||
val = (val+JSON.parse(res[j][5])[i])/2
|
||||
val = (val+JSON.parse(res[j][4])[i])/2
|
||||
}
|
||||
res_arr.push(Math.round(val));
|
||||
}
|
||||
@@ -375,9 +375,9 @@ class FilterQueue{
|
||||
val = 0;
|
||||
//modify JSON.parse(res[0][5]) and initial i to control the range of the months
|
||||
for (var i=start_cnt; i<end_cnt;i++){
|
||||
val = JSON.parse(res[0][5])[i]
|
||||
val = JSON.parse(res[0][4])[i]
|
||||
for (var j=1;j<res.length;j++){
|
||||
val += JSON.parse(res[j][5])[i]
|
||||
val += JSON.parse(res[j][4])[i]
|
||||
}
|
||||
val+=Math.round(val)
|
||||
}
|
||||
@@ -396,7 +396,7 @@ class FilterQueue{
|
||||
//formulate graph object
|
||||
var graph_lst = []
|
||||
for (var i=0; i<plotlst.length;i++){
|
||||
graph_lst.push({"lineTension":0.3, label:"Query "+String(i+1), "data": plotlst[i], borderWidth:1})
|
||||
graph_lst.push({"lineTension":0.3, label:"Query #"+String(i+1), "data": plotlst[i], borderWidth:1})
|
||||
}
|
||||
|
||||
var pie_lbl = [];
|
||||
@@ -405,7 +405,7 @@ class FilterQueue{
|
||||
|
||||
//why don't we generate the bg colour as well
|
||||
for (var i=0; i<pielst.length;i++){
|
||||
pie_lbl.push("Query "+String(i+1))
|
||||
pie_lbl.push("Query #"+String(i+1))
|
||||
pie_colour.push(random_rgba())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user