LinePlot = {
const container = Container
const width = 500
const height = 100
const svg = d3
.select(container)
.append("svg")
.attr("viewBox", `0 0 ${width} ${height}`);
const data = d3.pairs(data_synth)
console.log(data)
const div = d3
.select(container)
.append("div")
.classed("tooltip", true);
const tooltip = new Tooltip(div);
function tooltipContents(datum) {
const [ a, b ] = [datum[0], datum[1]];
const text = `(${a.date}, ${a.close})<br>(${b.date}, ${b.close})`;
return text
}
svg.append("path")
.attr("fill", "None")
.attr("stroke", "steelblue")
.attr("stroke-width", 1.5)
.attr("stroke-miterlimit", 1)
.attr("d", line(data_synth));
svg.append("g")
.attr("fill", "none")
.selectAll("rect")
.data(data)
.join("rect")
.attr("x", ([a, b]) => x(a.date))
.attr("height", height)
.attr("width", ([a, b]) => x(b.date) - x(a.date))
.attr('fill','red').attr('opacity','.5')
.on("mouseout", () => tooltip.hide())
.on("mousemove", event => tooltip.move(event))
.on("mouseover", (event, d) => {tooltip.display(d, tooltipContents);
})
return container
}