class Tooltip {
constructor({ x, y }) {
this._x = x;
this._y = y;
this._date = svg`<text y="-30"></text>`;
this._debt = svg`<text y="-12"></text>`;
this._line = svg`<line x1="0" y1="0" x2="0" y2="${height -
margin.bottom -
margin.top}" stroke=${colors.axis} stroke-dasharray="2" />`;
this.node = svg`
<g pointer-events="none" display="none" font-family="'Helvetica Neue', sans-serif" font-size="12" text-anchor="middle">
${this._line}
<rect x="-35" width="70" y="-45" height="40" fill="#FFFFFF"></rect>
${this._date}
${this._debt}
<circle r="2.5"></circle>
</g>
`;
}
show(d) {
this.node.removeAttribute("display");
this.node.setAttribute(
"transform",
`translate(${this._x(d.date)},${this._y(d.value)})`
);
this._date.textContent = formatDate(d.date);
this._debt.textContent = formatDebt(d.value);
this._line.setAttribute(
"transform",
`translate(0, ${this._y(d.value) * -1 + margin.top})`
);
}
hide() {
this.node.setAttribute("display", "none");
}
}