updateSVG = function(simGroup){
let svg = d3.selectAll("svg")
svg.selectAll('path').remove()
svg.selectAll('line').remove()
svg.selectAll('g').remove()
svg.selectAll('text').remove()
addLegendSVG()
simNames.forEach( (simN) => {
let daysIn = simGroup[simN].cumulInfections.length
let xScale = d3.scaleLinear()
.domain([0, simGroup[simN].cumulInfections.length < 40 ? 40 : 10 * Math.ceil(daysIn / 10 )])
.range([55, 440])
let yScale = d3.scaleLinear().domain([0,popParams[simN].popSize]).range([215, 25])
let data = simGroup[simN]
d3.select("#line-chart-" + simN).selectAll('line')
.data([0,1,2,3]).enter().append('line').attr('stroke','#CCC').attr('x1', 50).attr('x2', 440)
.attr('y1', d=> 25 + d*(190/4)).attr('y2', d=> 25 + d*(190/4))
d3.select("#line-chart-" + simN).append("g").selectAll('line')
.data([...Array(Math.ceil(daysIn/ (daysIn > 60 ? 28 : 7)))]).enter().append('line')
.attr('stroke','#CCC').attr('x1', (d,i) => xScale(i*(daysIn > 60 ? 28 : 7))).attr('x2', (d,i) => xScale(i*(daysIn > 60 ? 28 : 7))).attr("stroke-dasharray","5,5")
.attr('y1','215').attr('y2', '25')
d3.select("#line-chart-" + simN).append("path")
.datum(data.cumulInfections)
.attr("fill", "none").attr("stroke", "steelblue").attr("stroke-width", 2)
.attr("d", d3.line()
.x((d,i) => xScale(i) )
.y(d =>yScale(d))
)
d3.select("#line-chart-" + simN).append("path")
.datum(data.curInfections)
.attr("fill", "none").attr("stroke", "orange").attr("stroke-width", 2)
.attr("d", d3.line()
.x((d,i) => xScale(i) )
.y(d =>yScale(d))
)
d3.select("#line-chart-"+simN).append("g").attr("transform", "translate(0,215)").call(d3.axisBottom(xScale))
d3.select("#line-chart-"+simN).append("text").attr("transform","translate(250,245)").style("text-anchor", "middle").style("font-size","12").text("Days");
d3.select("#line-chart-"+simN).append("g").attr("transform", "translate(55,0)").call(d3.axisLeft(yScale))
d3.select("#line-chart-"+simN).append("text").attr("transform", "translate(14,125) rotate(-90)").style("text-anchor", "middle").style("font-size","12").text("Count");
});
}