Skip to content

Commit f4db0e8

Browse files
508312ryantrinh05
andauthored
Small bitbyte tree additions (#594)
Sorting by age, data additions. --------- Co-authored-by: ryantrinh05 <[email protected]>
1 parent 433e429 commit f4db0e8

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

hknweb/static/bit_byte_tree_data.csv

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ kaitlynlee,drakelin
5757
kaitlynlee,rohintangirala
5858
nfigueira,drakelin
5959
nfigueira,rohintangirala
60+
srig,tarunamarnath
61+
vidishgupta,tarunamarnath
6062
alberttang,andrewzhang2001
6163
katherineshu,andrewzhang2001
6264
austinapatel,aganesh10
@@ -469,14 +471,15 @@ anvitha,nandiniagarwal
469471
anvitha,lydiaignatova
470472
anvitha,daniel_chang
471473
anvitha,bill.cy.zheng
472-
saamahme,tarunamarnath
473474
saamahme,kdurani
474475
saamahme,rishi.madala
475476
saamahme,harivall
476-
anixsarkar,tarunamarnath
477477
anixsarkar,kdurani
478478
anixsarkar,rishi.madala
479479
anixsarkar,harivall
480+
tarunamarnath,kdurani
481+
tarunamarnath,rishi.madala
482+
tarunamarnath,harivall
480483
alexfung,pranavsukumar
481484
alexfung,hsw1018
482485
alexfung,bhatsavit
@@ -558,9 +561,11 @@ richeldhaliwal,heather.ding
558561
richeldhaliwal,rishi.nath
559562
richeldhaliwal,quangnguyenln
560563
amoghgupta,kamal.nahas
564+
amoghgupta,hgn
561565
amoghgupta,varunbharadwaj
562566
amoghgupta,arda.akman
563567
jakebringetto,kamal.nahas
568+
jakebringetto,hgn
564569
jakebringetto,varunbharadwaj
565570
jakebringetto,arda.akman
566571
sanchez,owent

hknweb/templates/about/bitbyte_tree.html

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686

8787
{% block content %}
8888
<div class="svg-container">
89-
<button id="settings-toggle-btn" class="settings-toggle-btn">Info</button>
89+
<button id="settings-toggle-btn" class="settings-toggle-btn">Search</button>
9090

9191
<div id="settings-panel" class="settings-panel">
9292
<h4>Graph Settings</h4>
@@ -138,7 +138,7 @@ <h4>Search</h4>
138138
const baseNodeRadius = 5;
139139
const clickedNodeRadius = 7;
140140

141-
async function renderd3() {
141+
async function renderd3() {
142142
// Current clicked node.
143143
let activeNode = null;
144144
// Current hovered node.
@@ -150,7 +150,17 @@ <h4>Search</h4>
150150

151151
// Copy nodes and links. Simulation changes original data.
152152
const links = data.links.map(d => ({...d}));
153-
const nodes = data.nodes.map(d => ({...d}));
153+
154+
155+
const years = new Set(data.nodes.map(d => (d.candidate_semester)));
156+
const smallestYear = d3.min(years);
157+
const biggestYear = d3.max(years);
158+
const yearDifference = biggestYear - smallestYear;
159+
// Set initial positions to be higher the older the person's registration date is.
160+
// Idk if it actually works, but I think it did something.
161+
const nodes = data.nodes.map(d => ({...d,
162+
x: 0,
163+
y: (d.candidate_semester - smallestYear) / yearDifference * height}));
154164

155165
const simulation = d3.forceSimulation(nodes)
156166
.force("link", d3.forceLink(links).id(d => d.id))
@@ -179,7 +189,6 @@ <h4>Search</h4>
179189
.attr('d', 'M0,-5L10,0L0,5') // Path for the arrowhead (a triangle)
180190
.attr('fill', "#999");
181191

182-
183192
// Add a line for each link, and a circle for each node.
184193
const link = graph.append("g")
185194
.attr("stroke-opacity", 0.6)
@@ -596,7 +605,7 @@ <h4>Search</h4>
596605
if (settingsPanel.classList.contains('open')) {
597606
settingsToggleBtn.textContent = 'Close';
598607
} else {
599-
settingsToggleBtn.textContent = 'Settings';
608+
settingsToggleBtn.textContent = 'Search';
600609
}
601610
});
602611
} else {

hknweb/views/bitbyte_tree.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ def bitbyte_tree_data(request):
2727
for byte in all_bytes:
2828
user = User.objects.get(username__iexact=byte)
2929
data["nodes"].append(
30-
{"id": byte, "name": user.first_name + " " + user.last_name}
30+
{
31+
"id": byte,
32+
"name": user.first_name + " " + user.last_name,
33+
"candidate_semester": user.date_joined.year,
34+
}
3135
)
3236

3337
for byte in byte_bits:

0 commit comments

Comments
 (0)