{ const width = 800;
const height = 200;
const marginLeft = 20;
const marginRight = 0;
const marginBottom = 0;
const marginTop = 0;
const smallFont = 12;
const medFont = 14;
const bigFont = 20;
const lightGray = "#999";
const medGray = "#777";
const darkGray = "#444";
const svg = d3
.create("svg")
.attr("viewBox", [0, 0, width*1.3, height*1.1])
const xScale = d3
.scaleTime()
.domain([Date.now() - 900 * 365.24 * 24 * 60 * 60 * 1000, Date.now()])
.range([0, width-marginRight]);
const yScale = d3
.scaleLinear()
.domain([10,0])
.range([0, height]);
const xAxis = d3.axisBottom(xScale);
svg
.append("g")
.attr("class", "axis x-axis")
.attr("transform", `translate(${marginLeft},${height})`)
.call(xAxis)
.append("text")
.attr("class", "axis-label")
.attr("x", "45%")
.attr("dy", "3em")
.text(`text`)
.attr("font-size", medFont)
.attr("fill", "none");
const yAxis = d3.axisLeft(yScale);
svg
.append("g")
.attr("class", "axis y-axis")
.attr("transform", `translate(${marginLeft},${0})`)
.call(yAxis)
.append("text")
.attr("class", "axis-label")
.attr("y", "50%")
.attr("dx", "-3em")
.attr("writing-mode", "vertical-rl")
.text(" ")
.attr("font-size", medFont)
.attr("fill", medGray)
const rect =
svg.selectAll("rect")
.data(typed_data)
.join("rect")
.attr("x", (d) => xScale(d.setting_start_year) + marginLeft)
.attr("y", (d) => yScale(d.f_nf_num))
.attr("width", (d) => xScale(d.setting_end_year - d.setting_start_year))
.attr("height", 20)
.attr("fill", lightGray)
.attr("opacity", .15)
.attr("stroke", "black")
svg.on("click", function() {
d3.selectAll('rect')
.attr("opacity", 0.15)
.attr("stroke", "black")
})
const tooltip1 = svg
.append("g");
svg
.selectAll("rect")
.on("mouseover", function(d) {
tooltip1.call(callout, `${d.title}, ${d.author}
set c. ${d.setting_start_year}-${d.setting_end_year}`)
tooltip1.attr("transform",
`translate(${xScale(1550)}, ${yScale(3)})`)
.transition()
.duration(500)
.attr("fill-opacity", 0.8)
})
return svg.node();
}