kandy 0.8.0 Help

USA States Election Results Map (Joined Datasets)

val usaStates = GeoDataFrame.readGeoJson("https://raw.githubusercontent.com/AndreiKingsley/datasets/refs/heads/main/USA.json") val name by column<String>() val geometry by column<Geometry>() val usaAdjusted = usaStates.modify { update(geometry).where { name() == "Alaska" }.with { it.scaleAroundCenter(0.5).translate(40.0, -40.0) } // move Hawaii and Puerto Rico .update(geometry).where { name() == "Hawaii" }.with { it.translate(65.0, 0.0) } .update(geometry).where { name() == "Puerto Rico" }.with { it.translate(-10.0, 5.0) } } val usa2024electionResults = DataFrame.readCSV("https://gist.githubusercontent.com/AndreiKingsley/348687222aecc4f0eb39e3d81acd515b/raw/a9914352dbdfb426f9146dda633ee382d936b000/usa_2024_election_states.csv") val winner by column<String>() val usaStatesWithElectionResults = usaAdjusted.modify { innerJoin(usa2024electionResults) { name } } usaStatesWithElectionResults.plot { geoMap { fillColor(winner) { scale = categorical( "Republican" to Color.hex("#CC3333"), "Democrat" to Color.hex("#3366CC") ) } tooltips(name, winner) } layout { title = "USA 2024 President Election Results" size = 700 to 500 style(Style.Void) { legend.position = LegendPosition.Top } } }
usa_election_results_joined
Last modified: 08 February 2025