{
const height = width;
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
const margin = ({top: 20, right: 30, bottom: 80, left: 40});
const x = d3.scaleBand()
.domain(data_month.map(d => d[0]))
.rangeRound([margin.left, width - margin.right])
.padding(0.1)
const y = d3.scaleLinear()
.domain([20, d3.max(data_month, d => d[1])])
.rangeRound([height - margin.bottom, margin.top]);
const xAxis = g => g
.attr("transform", `translate(0,${height - margin.bottom})`)
.call(d3.axisBottom(x)
.tickValues(data_month.map(d => d[0]).filter(v => v.endsWith("-01") || v.endsWith("-07")))
.tickSizeOuter(0))
const yAxis = g => g
.attr("transform", `translate(${margin.left},0)`)
.style("color", "steelblue")
.call(d3.axisLeft(y).ticks(null, "s"))
.call(g => g.select(".domain").remove())
.call(g => g.append("text")
.attr("x", -margin.left)
.attr("y", 10)
.attr("fill", "currentColor")
.attr("text-anchor", "start")
.text(data_month.y))
svg.append("g")
.attr("fill", "steelblue")
.attr("fill-opacity", 0.8)
.selectAll("rect")
.data(data_month)
.join("rect")
.attr("x", d => x(d[0]))
.attr("width", x.bandwidth())
.attr("y", d => y(d[1]))
.attr("height", d =>(y(20) - y(d[1])));
svg.append("g")
.attr("fill", "none")
.attr("pointer-events", "all")
.selectAll("rect")
.data(data_month)
.join("rect")
.attr("x", d => x(d.year))
.attr("width", x.bandwidth())
.attr("y", 0)
.attr("height", height)
svg.append("g")
.call(xAxis);
svg.append("g")
.call(yAxis);
return svg.node();
}