Tooltip follows marker on single value history charts

This commit is contained in:
Marshall Polaris 2022-10-04 13:57:33 -07:00
parent ce530af501
commit 1e70e30f82

View File

@ -299,7 +299,7 @@ export const SingleValueHistoryChart = <P extends HistoryPoint>(props: {
}, [w, h, yKind, xScale, yScale]) }, [w, h, yKind, xScale, yScale])
const selector = dataAtPointSelector(data, xScale) const selector = dataAtPointSelector(data, xScale)
const onMouseOver = useEvent((mouseX: number, mouseY: number) => { const onMouseOver = useEvent((mouseX: number) => {
const p = selector(mouseX) const p = selector(mouseX)
props.onMouseOver?.(p.prev) props.onMouseOver?.(p.prev)
const x0 = p.prev ? xScale(p.prev.x) : xScale.range()[0] const x0 = p.prev ? xScale(p.prev.x) : xScale.range()[0]
@ -310,7 +310,7 @@ export const SingleValueHistoryChart = <P extends HistoryPoint>(props: {
if (p.prev && markerY) { if (p.prev && markerY) {
setMouse({ setMouse({
x: mouseX, x: mouseX,
y: mouseY, y: markerY,
y0: py0, y0: py0,
y1: markerY, y1: markerY,
data: p.prev, data: p.prev,