From c8c7e0550a3b61e48f93d68025f02043d837b0e6 Mon Sep 17 00:00:00 2001 From: Erica Dong Date: Sat, 13 Jan 2024 23:29:55 -0500 Subject: [PATCH] Fix gray --- src/components/Dashboard/Dashboard.js | 2 +- src/components/Dashboard/Flow.js | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/components/Dashboard/Dashboard.js b/src/components/Dashboard/Dashboard.js index 25027cd..14db7ed 100644 --- a/src/components/Dashboard/Dashboard.js +++ b/src/components/Dashboard/Dashboard.js @@ -124,12 +124,12 @@ function Dashboard() { let y = 0; function setCourses() { + console.log(data); tempCourses = []; tempEdges = []; let encounteredCodes = new Set(); for (var i = 0; i < data.Report_Entry.length; i++) { - // console.log(data.Report_Entry[i]["Course_Section_Owner"]) if ( data.Report_Entry[i]["Course_Section_Owner"] == department && !courseTracking.includes(data.Report_Entry[i]["Course_Title"]) diff --git a/src/components/Dashboard/Flow.js b/src/components/Dashboard/Flow.js index 564e4a2..fdd82d5 100644 --- a/src/components/Dashboard/Flow.js +++ b/src/components/Dashboard/Flow.js @@ -35,7 +35,6 @@ const lerpColor = (h1, h2, progress) => { } const getLayoutedElements = (nodes, edges, colorSchema, coursesTaken, options = {}) => { - console.log("changed"); const easyColor = 125; const hardColor = -50; const codesLeft = new Set(); @@ -46,18 +45,21 @@ const getLayoutedElements = (nodes, edges, colorSchema, coursesTaken, options = children: nodes.map((node) => { const courseRating = classRatings[node.courseCode] ? classRatings[node.courseCode] : Math.round(Math.random() * 100); const profRating = profRatings[node.professor] ? profRatings[node.professor] : Math.round(Math.random() * 100); + // shouldn't be nan so often const projRating = 0.6 * profRating + 0.4 * courseRating; + // console.log(profRatings[node.professor] + " " + node.professor) + let gradRe = new RegExp("[A-Z]{2,3} [5-9][0-9]*") let style = {}; switch (colorSchema) { case "tot": - style.backgroundColor = lerpColor(hardColor, easyColor, projRating/100); + style.backgroundColor = lerpColor(hardColor, easyColor, projRating/100.0); break; case "prof": - style.backgroundColor = lerpColor(hardColor, easyColor, profRating/100); + style.backgroundColor = lerpColor(hardColor, easyColor, profRating/100.0); break; case "course": - style.backgroundColor = lerpColor(hardColor, easyColor, courseRating/100); + style.backgroundColor = lerpColor(hardColor, easyColor, courseRating/100.0); break; // case 'level': // style = { @@ -67,6 +69,10 @@ const getLayoutedElements = (nodes, edges, colorSchema, coursesTaken, options = default: style = {}; } + if (codesLeft.has(node.courseCode)) { + style.backgroundColor = "rgb(138, 138, 138)"; + style.color = "rgb(225, 225, 225)"; + } return { ...node, @@ -137,9 +143,7 @@ function FlowWithoutProvider({initialNodes, initialEdges, colorSchema, coursesTa function onNodeClick(event, node) { setIsModalOpen(true); - setCourseCode(node.data.label.substring(0, 8)); - - console.log(node.data.label.substring(0, 8)); + setCourseCode(node.courseCode); // Do something when a node is clicked };