class Tooltip {
constructor() {
this._date = svg`<text y="-22"></text>`;
this._close = svg`<text y="-12"></text>`;
this.node = svg`
<g pointer-events="none" display="none" font-family="sans-serif" font-size="10" text-anchor="middle">
<rect x="-27" width="54" y="-30" height="20" fill="white"></rect>
${this._date}
${this._close}
<circle r="2.5"></circle>
</g>`;
}
show(d) {
this.node.removeAttribute("display");
this.node.setAttribute("transform", `translate(${x(d.date)},${y(d.close)})`);
this._date.textContent = formatDate(d.date);
this._close.textContent = formatClose(d.close);
}
hide() {
this.node.setAttribute("display", "none");
}
}