Skip to content

Commit

Permalink
Update script.js
Browse files Browse the repository at this point in the history
  • Loading branch information
fmadore authored May 14, 2024
1 parent 867a5a7 commit 6180292
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Book_DeGruyter/Timeline/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ document.addEventListener('DOMContentLoaded', function() {
{"country": "Togo", "event": "Implementation of the LMD reform", "date": "2008-07-21"},
{"country": "Benin", "event": "Implementation of the LMD reform", "date": "2010-06-11"},
];

const margin = {top: 20, right: 20, bottom: 30, left: 50},
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
Expand Down Expand Up @@ -88,7 +88,17 @@ document.addEventListener('DOMContentLoaded', function() {

const filteredData = selectedCategory === "all" ? data : data.filter(d => d.category === selectedCategory);

eventPoints.data(filteredData)
const circles = svg.selectAll(".event")
.data(filteredData, d => d.event);

circles.exit().remove();

circles.enter().append("circle")
.attr("class", d => `event ${d.country}`)
.attr("cx", d => x(d.date))
.attr("cy", d => y(d.country) + y.bandwidth() / 2)
.attr("r", 5)
.merge(circles)
.attr("cx", d => x(d.date))
.attr("cy", d => y(d.country) + y.bandwidth() / 2)
.attr("r", 5);
Expand Down

0 comments on commit 6180292

Please sign in to comment.