plot1 =
{
var margin = {top: 60, right: 20, bottom: 30, left: 50},
width = 700 - margin.left - margin.right,
height = 365 - margin.top - margin.bottom;
const svg = d3.select(DOM.svg(width, height));
let x = d3.scaleLinear()
.domain(d3.extent([{date: 2012, value: 2430}, {date: 2020, value: 4109}], d => d.date))
.range([margin.left, width - margin.right])
let y = d3.scaleLinear()
.domain([0, d3.max([{date: 2012, value: 2430}, {date: 2020, value: 4109}], d => d.value)]).nice()
.range([height - margin.bottom, margin.top])
let xAxis = g => g
.attr("transform", `translate(0,${height - margin.bottom})`)
.call(d3.axisBottom(x).ticks(width / 80).tickSizeOuter(0).tickFormat(d3.format("d")))
let yAxis = g => g
.attr("transform", `translate(${margin.left},0)`)
.call(d3.axisLeft(y))
.call(g => g.select(".domain").remove())
.call(g => g.select(".tick:last-of-type text").clone()
.attr("x", 3)
.attr("text-anchor", "start")
.attr("font-weight", "bold")
.text([{date: 2012, value: 2398}, {date: 2020, value: 3118}].y))
let line = d3.line()
.defined(d => !isNaN(d.value))
.x(d => x(d.date))
.y(d => y(d.value))
svg.append("g")
.call(xAxis);
svg.append("g")
.call(yAxis);
let path = svg.append("path")
.attr("d", line([{date: 2012, value: 2398}, {date: 2020, value: 3118}]))
.attr("stroke", "#BF1F2C")
.attr("stroke-width", "3")
.attr("class", "line")
.attr("fill", "none");
let path2 = svg.append("path")
.attr("d", line([{date: 2012, value: 2478}, {date: 2016, value: 2198}, {date: 2018, value: 2590}, {date: 2020, value: 3281}]))
.attr("stroke", "#D9737B")
.attr("stroke-width", "3")
.attr("class", "line")
.attr("fill", "none");
let path3 = svg.append("path")
.attr("d", line([{date: 2012, value: 3072}, {date: 2016, value: 3305}, {date: 2018, value: 3943}, {date: 2020, value: 4689}]))
.attr("stroke", "#021F59")
.attr("stroke-width", "3")
.attr("class", "line")
.attr("fill", "none");
let path4 = svg.append("path")
.attr("d", line([{date: 2012, value: 2430}, {date: 2016, value: 2929}, {date: 2018, value: 3703}, {date: 2020, value: 4109}]))
.attr("stroke", "#4D688C")
.attr("stroke-width", "3")
.attr("class", "line")
.attr("fill", "none");
var totalLength = path.node().getTotalLength()
d3.select("#startLine").on("click", function() {
path
.attr("stroke-dasharray", totalLength + " " + totalLength)
.attr("stroke-dashoffset", totalLength)
.transition()
.duration(10000)
.ease(d3.easeLinear)
.attr("stroke-dashoffset", 0)
path2
.attr("stroke-dasharray", totalLength + " " + totalLength)
.attr("stroke-dashoffset", totalLength)
.transition()
.duration(10000)
.ease(d3.easeLinear)
.attr("stroke-dashoffset", 0)
path3
.attr("stroke-dasharray", totalLength + " " + totalLength)
.attr("stroke-dashoffset", totalLength)
.transition()
.duration(10000)
.ease(d3.easeLinear)
.attr("stroke-dashoffset", 0)
path4
.attr("stroke-dasharray", totalLength + " " + totalLength)
.attr("stroke-dashoffset", totalLength)
.transition()
.duration(10000)
.ease(d3.easeLinear)
.attr("stroke-dashoffset", 0)
})
return svg.node();
}