Append the following code immediately after .append("svg") to the SVG you want to be responsive.
.attr("preserveAspectRatio", "xMidYMid meet")
.attr("viewBox", `0 0 ${width} ${height}`)
.append("g").attr("width", width).attr("width", height)
width refers to the width of your SVG (prior to being responsive)
height refers to the height of your SVG (prior to being responsive)
Ex. let width = 960, height = 500;