From ef2c063b61137b18a2b7d6f8ece16c8f6e9e035f Mon Sep 17 00:00:00 2001 From: Luke Knipe Date: Tue, 3 Dec 2024 19:24:13 -0700 Subject: [PATCH] Updates --- index.html | 68 +++++++++++++++++++++++------------------------------- style.css | 45 ++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 39 deletions(-) diff --git a/index.html b/index.html index 5dc3600..07d3849 100644 --- a/index.html +++ b/index.html @@ -12,25 +12,25 @@ gtag('js', new Date()); gtag('config', 'G-DM5K75JW4Z'); - Voter Registration in Arizona's Legislative Districts + The 2024 Presidential Election in Pima County - - + + - + - + - + - + @@ -51,13 +51,13 @@ // Display basemap - var map = L.map('map', {zoomControl: false}).setView([32.1, -111.9], 8.8); + var map = L.map('map', {zoomControl: false}).setView([32.2, -111], 10.5); new L.Control.Zoom({ position: 'bottomleft' }).addTo(map); L.tileLayer('https://api.mapbox.com/styles/v1/lukeknipe/cl5mwyk7000gy15qvyp46e1h2/tiles/256/{z}/{x}/{y}@2x?access_token=pk.eyJ1IjoibHVrZWtuaXBlIiwiYSI6ImNsNW13ajU1azAwZmszZXBxeWV0ZWtlaTgifQ.llc0hOFsg4QzV7tiR1jLdg', { maxZoom: 18, - attribution: 'Map data: AIRC' + - ' | Voter data: Arizona Secretary of State Registration Report, July 2023 | Imagery © Mapbox', + attribution: 'Map data: Pima County Geospatial Data Portal' + + ' | Election data: Pima County Elections Department | Imagery © Mapbox', }).addTo(map); // Control that shows district info on hover @@ -72,36 +72,30 @@ info.update = function (props) { this._div.innerHTML = (props ? - '

Precinct
' + props.PRECINCT - + '

' + ((props.TRUMP / (props.BALLOTS_CA))*100).toFixed(2) + '% Trump ' - + '

' + props.TRUMP + ' Votes for Donald Trump' - + '

' + + ((props.HARRIS / (props.BALLOTS_CA))*100).toFixed(2) + '% Harris ' - + '

' + props.HARRIS + ' Votes for Kamala Harris' - + '

' + (((props.OLIVER + props.STEIN + props.WRITE_IN) / (props.BALLOTS_CA))*100).toFixed(2) + '% Others' - + '

' + props.OLIVER + ' Votes for Chase Oliver' - + '

' + props.STEIN + ' Votes for Jill Stein' - + '

' + props.WRITE_IN + ' Write-in votes' - + '

' + leanCalc(((props.TRUMP / (props.BALLOTS_CA))*100).toFixed(2), ((props.HARRIS / (props.BALLOTS_CA))*100).toFixed(2)) - + '
' + props.DEM + ' Democrats ' - + '
' + props.OTR + ' Others ' - + '
' + props.LIB + ' Libertarians ' - + '
' + props.NL + ' No Labels ' - + '
' + (props.DEM + props.REP + props.LIB + props.OTR + props.NL) + ' Total ' - + '
Senator
' - + props.SEN - + '

House Reps
' - + props.HSE - + '
' - : 'Hover over a
legislative district'); + '

Precinct
' + props.PRECINCT + '

' + + '

Turnout ' + props.TURNOUT + '%

' + + '

' + leanCalc(((props.TRUMP / (props.BALLOTS_CA))*100).toFixed(2), ((props.HARRIS / (props.BALLOTS_CA))*100).toFixed(2)) + '

' + + '


' + ((props.TRUMP / (props.BALLOTS_CA))*100).toFixed(2) + '% Trump

' + + '


' + props.TRUMP + ' Votes for Donald Trump

' + + '


' + + ((props.HARRIS / (props.BALLOTS_CA))*100).toFixed(2) + '% Harris

' + + '


' + props.HARRIS + ' Votes for Kamala Harris

' + + '


' + (((props.OLIVER + props.STEIN + props.WRITE_IN) / (props.BALLOTS_CA))*100).toFixed(2) + '% Others

' + + '


' + props.OLIVER + ' Votes for Chase Oliver

' + + '


' + props.STEIN + ' Votes for Jill Stein

' + + '


' + props.WRITE_IN + ' Write-in votes

' + + '


' + + ((props.UNDER_VOTE / (props.BALLOTS_CA))*100).toFixed(2) + '% Undervote

' + + '


' + props.UNDER_VOTE + ' Undervotes

' + + '


' + props.OVER_VOTE + ' Overvotes

' + : 'Hover over a voting precinct'); }; info.addTo(map); function leanCalc(pctRep, pctDem) { if (pctRep > pctDem) { - return '
Trump by ' + (pctRep - pctDem).toFixed(2) + '%
'; + return '
Trump + ' + (pctRep - pctDem).toFixed(2) + '%
'; } else { - return '
Harris by ' + (pctDem - pctRep).toFixed(2) + '%
'; + return '
Harris + ' + (pctDem - pctRep).toFixed(2) + '%
'; } } @@ -148,7 +142,7 @@ opacity: 1, color: 'white', dashArray: '3', - fillOpacity: 0.7, + fillOpacity: 0.5, fillColor: getColorDem(demEdge), }; } @@ -225,7 +219,7 @@ var div = L.DomUtil.create('div', 'info legend'), grades = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90], - labels = ['Win
margin %

'], + labels = ['Harris/Trump
margin %

'], from, to; for (var i = 0; i < grades.length; i++) { @@ -247,8 +241,4 @@ -
- LK > Maps -
- \ No newline at end of file diff --git a/style.css b/style.css index 6fb3201..a182bb2 100644 --- a/style.css +++ b/style.css @@ -31,6 +31,51 @@ body, z-index: 0; } +h1 { + display: block; + text-align: center; + line-height: 1em; + font-size: 1.5em; + margin-top: 0.67em; + margin-bottom: 0.67em; + margin-left: 0; + margin-right: 0; + font-weight: bold; +} + +h2 { + display: inline; + font-size: 1.0em; + line-height: 1.3em; + margin-top: 0.67em; + margin-bottom: 0.67em; + margin-left: 0; + margin-right: 0; + font-weight: bold; +} + +h3 { + display: inline; + font-size: 1.0em; + margin-top: 0.67em; + margin-bottom: 0.67em; + margin-left: 0; + margin-right: 0; + font-weight: normal; +} + +h4 { + display: inline; + text-align: center; + line-height: .5em; + font-size: .75em; + margin-top: 0.67em; + margin-bottom: 0.67em; + margin-left: 0; + margin-right: 0; + font-weight: normal; +} + .info { padding: 6px 8px; font: 14px/16px Arial, Helvetica, sans-serif;