Created
September 4, 2021 22:23
-
-
Save russelllim22/28efccb175c20d71bbc3fabd2e387a07 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let xVar = document.getElementById("select-x-var").value; | |
document.getElementById("select-x-var").addEventListener("change", (e)=>{ | |
// update the x-variable based on the user selection | |
xVar = e.target.value | |
// rescale the x-axis | |
xScale = d3.scaleLinear() | |
.domain([0, d3.max(articleData, d => d[xVar]) ]) | |
.range([0, 600]); | |
// redraw the x-axis | |
svg.select("#xAxis") | |
.call(d3.axisBottom(xScale)) | |
// transition each circle element | |
svg.selectAll(".bubble") | |
.transition() | |
.duration(1000) | |
.attr("cx", (d) => xScale(d[xVar]) ) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment