Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
Added gradeint to chloropleth
Browse files Browse the repository at this point in the history
  • Loading branch information
JayMuppidi committed Apr 23, 2024
1 parent b29d4fb commit ba75c88
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
<div id="choropleth">
<svg width="100%" viewBox="0 0 2000 1000"></svg>
<script>
const colorScale = d3.scaleLinear()
.domain([0, 5])
.range(["#f0f0f0", "#4CAF50"]);
// here, I am trying to load the geoJSON file that is given to us
d3.json("https://enjalot.github.io/wwsd/data/world/world-110m.geojson").then(function (world) {
d3.csv("./data/WorldCupMatches.csv").then(function (data) {
Expand Down Expand Up @@ -91,7 +94,14 @@
.data(world.features)
.enter().append("path")
.attr("d", path)
.attr("fill", "white")
.attr("fill", d => {
// Get the name of the country
const countryName = d.properties.name;
// Get the number of trophies won by the country, defaulting to 0 if not found
const trophiesWon = winCount[countryName] || 0;
// Map the number of trophies to the color scale
return colorScale(trophiesWon);
})
.on("mouseover", function (event, d) {
// Transitioning to light blue
d3.select(this)
Expand Down

0 comments on commit ba75c88

Please sign in to comment.