Skip to content

Commit

Permalink
Merge pull request #62 from jacksonjude/cnn-counties
Browse files Browse the repository at this point in the history
CNN Counties
  • Loading branch information
jacksonjude authored Nov 21, 2024
2 parents 55713c6 + f11dd05 commit bac5d59
Show file tree
Hide file tree
Showing 7 changed files with 388 additions and 219 deletions.
328 changes: 164 additions & 164 deletions csv-sources/past-president-county.csv

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions src/display/control-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,15 @@ async function leftClickRegion(div)
var baseRegionID = getBaseRegionID($(div).attr('id')).baseID
currentViewingState = ViewingState.zooming
currentMapZoomRegion = regionID.includes(subregionSeparator) ? baseRegionID.split(subregionSeparator)[0] : baseRegionID

if (currentMapType.getID() == USAPresidentMapType.getID() && currentMapZoomRegion.includes("-"))
{
let stateID = currentMapZoomRegion.split("-")[0]
if (stateID == "NE" || stateID == "ME")
{
currentMapZoomRegion = stateID
}
}

displayDataMap(null, null, true)

Expand Down
10 changes: 4 additions & 6 deletions src/display/map-display.js
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,8 @@ async function displayDataMap(dateIndex, reloadPartyDropdowns, fadeForNewSVG)

updatePoliticalPartyCandidateNames(dateToDisplay.getTime())
displayPartyTotals(reloadPartyDropdowns)


// console.log(Object.keys(displayRegionDataArray)[0])
updateTotalsPieChart()

let iconOverlayText = currentMapSource.getIconOverlayText()
Expand Down Expand Up @@ -1412,14 +1413,11 @@ async function zoomOutMap(displayMap = true)
currentViewingState = ViewingState.viewing
currentMapZoomRegion = null

const countyResultMapSourceID = "Presidential-Counties"
if (showingCompareMap && currentMapType.getID() == USAPresidentMapType.getID() && compareMapSourceIDArray[0] == countyResultMapSourceID && compareMapSourceIDArray[1] == countyResultMapSourceID)
if (showingCompareMap && currentMapType.getID() == USAPresidentMapType.getID())
{
const pastResultMapSourceID = "Past-Presidential-Elections"
compareMapSourceIDArray = [pastResultMapSourceID, pastResultMapSourceID]
compareResultCustomMapSource = null
getCompareMajorParties = null
shouldSetCompareMapSource = currentMapSource.isCustom();
shouldSetCompareMapSource = currentMapSource.isCustom()

await updateCompareMapSources([true, true], true, false, [$("#firstCompareDataMapDateSlider").val(), $("#secondCompareDataMapDateSlider").val()])
shouldSetCompareMapSource = true
Expand Down
7 changes: 6 additions & 1 deletion src/model/map-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class MapSource
}
self.mapDates.sort((mapDate1, mapDate2) => (mapDate1-mapDate2))

let filterMapDataCallback = self.filterMapDataFunction(self.rawMapData, self.mapDates, self.columnMap, self.cycleYear, self.candidateNameToPartyIDMap, self.regionNameToIDMap, self.heldRegionMap, self.shouldFilterOutDuplicateRows, self.isCustomMap, self.voteshareCutoffMargin, !self.isCustomMap || self.editingMode == EditingMode.voteshare)
let filterMapDataCallback = self.executeFilter(self.rawMapData, self.mapDates, self)
self.mapData = filterMapDataCallback.mapData

if (filterMapDataCallback.candidateNameData != null && resetCandidateNames)
Expand Down Expand Up @@ -153,6 +153,11 @@ class MapSource

return true
}

executeFilter(rawData, mapDates, self = this, ...args)
{
return self.filterMapDataFunction(rawData, mapDates, self.columnMap, self.cycleYear, self.candidateNameToPartyIDMap, self.regionNameToIDMap, self.heldRegionMap, self.shouldFilterOutDuplicateRows, self.isCustomMap, self.voteshareCutoffMargin, !self.isCustomMap || self.editingMode == EditingMode.voteshare, ...args)
}

async loadMapCache(self, reloadCache, onlyAttemptLocalFetch)
{
Expand Down
239 changes: 198 additions & 41 deletions src/model/map-types/usa-president-map-type.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion svg-sources/source-updated-times.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"usa-counties-map.svg": 1666250246355,
"usa-counties-map.svg": 1732001746274,
"usa-governor-map.svg": 1666250246355,
"usa-house-1976-map.svg": 1666250246355,
"usa-house-1982-map.svg": 1666250246355,
Expand Down
12 changes: 6 additions & 6 deletions svg-sources/usa-counties-map.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit bac5d59

Please sign in to comment.