viewof context = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, heightcontext]);
const clipId2 = DOM.uid("clip");
svg.append("clipPath")
.attr("id", clipId2.id)
.append("rect")
.attr("x", margin2.left)
.attr("y", 0)
.attr("width", width - margin2.left - margin2.right)
.attr("height", heightcontext - margin2.bottom);
const brush = d3.brushX()
.extent([[margin2.left, 0], [width - margin2.right, heightcontext - margin2.bottom]])
.on("brush", brushed)
.on("end", brushended);
const defaultSelection = dayRange.map(xt);
svg.selectAll(".ttip")
.data(data)
.join("rect")
.attr("x", d => xt(d.start_time))
.attr("y", d => yt2(d.may_id))
.attr("width", d => xt(d.end_time) - xt(d.start_time))
.attr("height", yt2.bandwidth())
.attr("fill", d => colorScale(d.new_value))
.attr("clip-path", clipId2);
svg.append("g")
.attr("transform", `translate(0,${heightcontext - margin2.bottom})`)
.call(xAxis);
const gb = svg.append("g")
.call(brush)
.call(brush.move, defaultSelection);
function brushed({selection}) {
if (selection) {
svg.property("value", selection.map(xt.invert, xt));
svg.dispatch("input");
}
}
function brushended(event) {
const selection = event.selection;
if (!selection) { gb.call(brush.move, defaultSelection) };
if (!event.sourceEvent || !selection) return;
let dayRange = selection.map(d => d3.timeDay.round(xt.invert(d)));
dayRange[1] = d3.timeSecond.offset(dayRange[1],-1)
d3.select(this).transition().call(brush.move, dayRange.map(xt));
}
function updateBrush(daterange) {
d3.select(this).transition().call(brush.move, daterange)
}
return svg.node();
}