From 4d91b3727d969b4b6f2e45e01a3bd8cba4d0619e Mon Sep 17 00:00:00 2001 From: Matthew Huntington Date: Fri, 22 Sep 2023 23:30:42 -0400 Subject: [PATCH] all/none --- public/app.js | 67 ++++++++++++++++++++++++++++++++++++----------- public/index.html | 16 ++++++++--- 2 files changed, 63 insertions(+), 20 deletions(-) diff --git a/public/app.js b/public/app.js index 635355a..2a1deaa 100644 --- a/public/app.js +++ b/public/app.js @@ -7,8 +7,8 @@ const parseTime = d3.timeParse("%B %e, %Y"); let instances; let xScale, yScale; let highlighted = [] -const courses = []; -const metros = []; +let courses = [] +let metros = [] const randomColor = ()=>{ const red = Math.floor(Math.random()*128) + 64; @@ -147,19 +147,8 @@ const createFormSubmissionHandler = () => { } const populateMetrosCoursesCheckboxes = ()=>{ - for(let instance of instances){ - const segments = instance.course.split('-') - - if(metros.find(m => m.metro === segments[0]) === undefined){ - metros.push({ checked:true, metro: segments[0] }) - } - - if(courses.find(c => c.course === segments[1]) === undefined){ - courses.push({ checked:true, course: segments[1] }) - } - } - d3.select('#courses') + d3.select('#courses ul').html('') //TODO remove .html() somehow .selectAll('li') .data(courses) .enter() @@ -171,7 +160,7 @@ const populateMetrosCoursesCheckboxes = ()=>{ renderPoints() }) - d3.select('#metros') + d3.select('#metros ul').html('') //TODO remove .html() somehow .selectAll('li') .data(metros) .enter() @@ -182,11 +171,57 @@ const populateMetrosCoursesCheckboxes = ()=>{ datum.checked = !datum.checked renderPoints() }) + + d3.select('#courses button:nth-child(2)') + .on('click', ()=>{ + for(course of courses){ + course.checked = true + } + renderPoints() + populateMetrosCoursesCheckboxes() + }) + d3.select('#courses button:nth-child(3)') + .on('click', ()=>{ + for(course of courses){ + course.checked = false + } + renderPoints() + populateMetrosCoursesCheckboxes() + }) + + d3.select('#metros button:nth-child(2)') + .on('click', ()=>{ + for(metro of metros){ + metro.checked = true + } + renderPoints() + populateMetrosCoursesCheckboxes() + }) + d3.select('#metros button:nth-child(3)') + .on('click', ()=>{ + for(metro of metros){ + metro.checked = false + } + renderPoints() + populateMetrosCoursesCheckboxes() + }) } window.onload = async ()=>{ instances = await d3.json('/instances'); - populateMetrosCoursesCheckboxes(); + for(let instance of instances){ + const segments = instance.course.split('-') + + if(metros.find(m => m.metro === segments[0]) === undefined){ + metros.push({ checked:true, metro: segments[0] }) + } + + if(courses.find(c => c.course === segments[1]) === undefined){ + courses.push({ checked:true, course: segments[1] }) + } + + } + populateMetrosCoursesCheckboxes() setupGraph(); createAxes(); renderPoints(); diff --git a/public/index.html b/public/index.html index 87b943d..7576b5c 100644 --- a/public/index.html +++ b/public/index.html @@ -18,10 +18,18 @@
Y-Axis:
Percentage of graduates that got a job within 90 days of graduation.
-

Choose Metros To Display

- -

Choose CoursesTo Display

- +
+

Choose Metros To Display

+ + + +
+
+

Choose Courses To Display

+ + + +