Skip to content

Commit

Permalink
added sort functionality back
Browse files Browse the repository at this point in the history
  • Loading branch information
zanewolf committed Mar 17, 2022
1 parent b6c3e61 commit 6376733
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 48 deletions.
20 changes: 11 additions & 9 deletions js/main_researchInterests.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function initMainPage(dataArray) {
let selectedFacultyTableFilterRI = $('#faculty-table-filter-research-selector').val();
let selectedFacultyTableFilterAA = $('#faculty-table-filter-academic-selector').val();
let selectedColorPalette = false;
var selectedSortTable = false;
//let newFilterBack = false;

function filterChangeFacultyTableAA() {
Expand All @@ -40,16 +41,17 @@ function filterChangeFacultyTableRI() {
myVisResearchInterests.wrangleData();
}

selectedFacultyTableFacultySort = $('#faculty-table-faculty-sort-selector').val();
function sortFacultyChangeFacultyTable() {
// sort table, via the faculty
selectedFacultyTableFacultySort = $('#faculty-table-faculty-sort-selector').val();
myVisResearchInterests.wrangleData();
}
selectedFacultyTableResearchSort = $('#faculty-table-research-sort-selector').val();
function sortResearchChangeFacultyTable() {
// selectedFacultyTableFacultySort = $('#faculty-table-faculty-sort-selector').val();
// function sortFacultyChangeFacultyTable() {
// // sort table, via the faculty
// selectedFacultyTableFacultySort = $('#faculty-table-faculty-sort-selector').val();
// myVisResearchInterests.wrangleData();
// }
// selectedFacultyTableResearchSort = $('#faculty-table-research-sort-selector').val();
function sortTable() {
// sort table, via research interests
selectedFacultyTableResearchSort = $('#faculty-table-research-sort-selector').val();
selectedSortTable =! selectedSortTable;
// selectedFacultyTableResearchSort = $('#faculty-table-research-sort-selector').val();
myVisResearchInterests.wrangleData();
}

Expand Down
84 changes: 48 additions & 36 deletions js/vis_researchInterests.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ class visResearchInterests {
sortAndFilterValues() {
let vis = this;
vis.noMatch = false;
vis.isAll = true;

// filter FIRST

Expand All @@ -220,11 +221,13 @@ class visResearchInterests {
// vis.displayFaculty = filteredFacultyRI;
// vis.xShift = 240;
vis.cellScalar = 0.7;
vis.isAll=false;
} else if (selectedFacultyTableFilterAA != "All" & selectedFacultyTableFilterRI == "All") {
vis.displayFaculty = vis.allFaculty.filter(name => vis.departmentMap[name].teachingAreas.includes(selectedFacultyTableFilterAA));
// vis.displayFaculty = filteredFacultyAA;
// vis.xShift = 240;
vis.cellScalar = 0.7;
vis.isAll = false;
} else if (selectedFacultyTableFilterRI == "All" && selectedFacultyTableFilterAA == "All") {
vis.displayFaculty = vis.allFaculty;
// vis.xShift = 50;
Expand All @@ -241,6 +244,7 @@ class visResearchInterests {
// vis.xShift=50;
vis.cellScalar=0.6;
}
vis.isAll=false;
}


Expand All @@ -256,23 +260,28 @@ class visResearchInterests {
// THEN sort

// sorting of faculty
// let stringFacultyInclusionSorts = ["name", "teachingAreas"];
// if (stringFacultyInclusionSorts.includes(selectedFacultyTableFacultySort)) {
// // compare strings
// vis.displayFaculty.sort(function(a, b){return vis.facultySortInfoDict[a][selectedFacultyTableFacultySort].localeCompare(vis.facultySortInfoDict[b][selectedFacultyTableFacultySort])});
// }
// else {
// // compare numbers (counts)
// vis.displayFaculty.sort(function(a, b){return vis.facultySortInfoDict[b][selectedFacultyTableFacultySort] - vis.facultySortInfoDict[a][selectedFacultyTableFacultySort]});
// }
//
// // sorting of research areas
// let stringResearchInclusionSorts = ["researchInterest"];
let stringFacultyInclusionSorts = ["name", "teachingAreas"];
let stringResearchInclusionSorts = ["researchInterest"];
let selectedFacultyTableFacultySort = ["name", "numResearchInterests"]
let selectedFacultyTableResearchSort = ['researchInterest', 'interestedFaculty']
if (!selectedSortTable) {
// compare strings
vis.displayFaculty.sort(function(a, b){return vis.facultySortInfoDict[a][selectedFacultyTableFacultySort[0]].localeCompare(vis.facultySortInfoDict[b][selectedFacultyTableFacultySort[0]])});
vis.displayResearchInterests.sort(function(a, b){return vis.researchInterestSortInfoDict[a][selectedFacultyTableResearchSort[0]].localeCompare(vis.researchInterestSortInfoDict[b][selectedFacultyTableResearchSort[0]])});

}
else {
// compare numbers (counts)
vis.displayFaculty.sort(function(a, b){return vis.facultySortInfoDict[b][selectedFacultyTableFacultySort[1]] - vis.facultySortInfoDict[a][selectedFacultyTableFacultySort[1]]});
vis.displayResearchInterests.sort(function(a, b){return vis.researchInterestSortInfoDict[b][selectedFacultyTableResearchSort[1]] - vis.researchInterestSortInfoDict[a][selectedFacultyTableResearchSort[1]]});
}

// sorting of research areas

// if (stringResearchInclusionSorts.includes(selectedFacultyTableResearchSort)) {
// vis.displayResearchInterests.sort(function(a, b){return vis.researchInterestSortInfoDict[a][selectedFacultyTableResearchSort].localeCompare(vis.researchInterestSortInfoDict[b][selectedFacultyTableResearchSort])});
// }
// }
// else {
// vis.displayResearchInterests.sort(function(a, b){return vis.researchInterestSortInfoDict[b][selectedFacultyTableResearchSort] - vis.researchInterestSortInfoDict[a][selectedFacultyTableResearchSort]});
//
// }

// update the cell widths so it scales, and maybe update whether or not text is shown
Expand Down Expand Up @@ -495,28 +504,31 @@ class visResearchInterests {
.attr('stroke-width', '2px')
.attr('stroke', 'black');
// update tooltip
vis.tooltip
.style("opacity", 1)
.html(`
<div style="border: thin solid grey; border-radius: 5px; background: lightgrey; padding: 20px">
<h4 style="text-align: center"><b>Column: </b>${d.name}</h4>
<h4 style="text-align: center"><b>Row: </b> ${d.researchInterest}</h4>
<p><b>Teaching Area:</b> ${vis.departmentMap[d.name].teachingAreas}
<br>
<b>Research Interests:</b> ${vis.departmentMap[d.name].researchInterests}
<br>
<b>Email:</b> ${vis.allInfoMap[d.name]["Email"]}
<br>
<b>Phone:</b> ${vis.allInfoMap[d.name]["Phone"]}
<br>
<b>Website:</b> ${vis.allInfoMap[d.name]["Website Link"]}
</p>
</div>`);

vis.tooltip
.style("left", (event.pageX - $("#researchInterestsTooltip").width()/2) + "px")

.style("top", (event.pageY - $("#researchInterestsTooltip").height() - 5) + "px")
if (vis.isAll | vis.noMatch) {
vis.tooltip
.style("opacity", 1)
.html(`
<div style="border: thin solid grey; border-radius: 5px; background: lightgrey; padding: 20px">
<h4 style="text-align: center"><b>Column: </b>${d.name}</h4>
<h4 style="text-align: center"><b>Row: </b> ${d.researchInterest}</h4>
<p><b>Teaching Area:</b> ${vis.departmentMap[d.name].teachingAreas}
<br>
<b>Research Interests:</b> ${vis.departmentMap[d.name].researchInterests}
<br>
<b>Email:</b> ${vis.allInfoMap[d.name]["Email"]}
<br>
<b>Phone:</b> ${vis.allInfoMap[d.name]["Phone"]}
<br>
<b>Website:</b> ${vis.allInfoMap[d.name]["Website Link"]}
</p>
</div>`);

vis.tooltip
.style("left", (event.pageX - $("#researchInterestsTooltip").width() / 2) + "px")

.style("top", (event.pageY - $("#researchInterestsTooltip").height() - 5) + "px")
}
})
.on('mouseout', function(event, d){
d3.select(this)
Expand Down
14 changes: 11 additions & 3 deletions vis_researchInterests.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h1> Faculty Research Area Comparison</h1>
</div>
</div>
<div class="row options">
<div class="col-3 justify-content-left">
<div class="col-3 justify-content-center">
<select id='faculty-table-filter-academic-selector' class="custom-select align-self-center" onchange="filterChangeFacultyTableAA()">
<option value="All">All Academic Areas</option>
</select>
Expand All @@ -39,7 +39,7 @@ <h1> Faculty Research Area Comparison</h1>
<div class="col-2 justify-content-center color-switch">
<div class="pretty p-switch p-fill cbf-switch" >
<input type="checkbox" value="false" onChange="changeColorPalette()" />
<div class="state p-primary" >
<div class="state" >
<label>Color-Blind Friendly</label>
</div>
</div>
Expand Down Expand Up @@ -67,7 +67,15 @@ <h1> Faculty Research Area Comparison</h1>
<!-- </select>-->
<!-- </div>-->
</div>
<div class="col-3 justify-content-left">
<div class="col-1 justify-content-center color-switch">
<div class="pretty p-switch p-fill cbf-switch" >
<input type="checkbox" value="false" onChange="sortTable()" />
<div class="state" >
<label>Sort</label>
</div>
</div>
</div>
<div class="col-3 justify-content-center">
<select id='faculty-table-filter-research-selector' class="custom-select align-self-center" onchange="filterChangeFacultyTableRI()">
<option value="All">All Research Interests</option>
</select>
Expand Down

0 comments on commit 6376733

Please sign in to comment.