chart = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
svg.append("g")
.attr("fill", "#8FC0FA")
.attr("fill-opacity", 0.8)
.selectAll("rect")
.data(data)
.join("rect")
.attr("x", d => x(d.bus))
.attr("width", x.bandwidth())
.attr("y", d => y(d.total))
.attr("height", d => y(0) - y(d.total));
svg.append("path")
.attr("fill", "none")
.attr("stroke", colors[0])
.attr("stroke-miterlimit", 1)
.attr("stroke-width", 3)
.attr("d", line1(data));
svg.append("path")
.attr("fill", "none")
.attr("stroke", colors[1])
.attr("stroke-miterlimit", 1)
.attr("stroke-width", 3)
.attr("d", line2(data));
svg.append("path")
.attr("fill", "none")
.attr("stroke", colors[2])
.attr("stroke-miterlimit", 1)
.attr("stroke-width", 3)
.attr("d", line3(data));
svg.append("text")
.attr("x", margin.left)
.attr("y", margin.top)
.attr("text-anchor", "middle")
.style("font-size", "12px")
.style("text-decoration", "underline")
.attr("stroke","#ffffff");
svg.append("g")
.attr("fill", "none")
.attr("pointer-events", "all")
.selectAll("rect")
.data(data)
.join("rect")
.attr("x", d => x(d.bus))
.attr("width", x.bandwidth())
.attr("y", 0)
.attr("height", height)
.append("title")
.text(d => `Bus ${d.bus}
Saturday Total Range ${d.total.toLocaleString("en")} km
Saturday Light Duty ${d.light.toLocaleString("en")} km
Saturday Medium Duty ${d.medium.toLocaleString("en")} km
Saturday Heavy Duty ${d.heavy.toLocaleString("en")} km`);
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis)
.selectAll("text")
.attr("y", 0)
.attr("x", 9)
.attr("dy", ".35em")
.attr("transform", "rotate(90)")
.style("text-anchor", "start")
.attr("stroke","#ffffff");
svg.append("g")
.call(yAxis)
.attr("stroke","#ffffff");
return svg.node();
}