Compare commits
1 Commits
5-remove-u
...
2-mouselea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c754316935 |
@@ -24,13 +24,15 @@ export default function UpsChart({ config, upsRows, timeMode, onEdit, onDelete }
|
|||||||
(el, w, h, lRef) => {
|
(el, w, h, lRef) => {
|
||||||
if (upsRows.length < 2) return null;
|
if (upsRows.length < 2) return null;
|
||||||
|
|
||||||
const data = timeMode === 'tick'
|
const sorted = [...upsRows].sort((a, b) =>
|
||||||
? [...upsRows].sort((a, b) => a.game_tick - b.game_tick)
|
timeMode === 'tick'
|
||||||
: upsRows;
|
? a.game_tick - b.game_tick
|
||||||
const xs = data.map((r) =>
|
: new Date(a.real_time).getTime() - new Date(b.real_time).getTime(),
|
||||||
|
);
|
||||||
|
const xs = sorted.map((r) =>
|
||||||
timeMode === 'tick' ? r.game_tick : new Date(r.real_time).getTime() / 1000,
|
timeMode === 'tick' ? r.game_tick : new Date(r.real_time).getTime() / 1000,
|
||||||
);
|
);
|
||||||
const ys = data.map((r) => r.ups);
|
const ys = sorted.map((r) => r.ups);
|
||||||
|
|
||||||
const xAxis: uPlot.Axis = {
|
const xAxis: uPlot.Axis = {
|
||||||
...AXIS_BASE,
|
...AXIS_BASE,
|
||||||
|
|||||||
@@ -57,11 +57,11 @@ export function usePlot(
|
|||||||
|
|
||||||
// Defer mouseleave — prevents React hydration events firing before lastIdxRef set
|
// Defer mouseleave — prevents React hydration events firing before lastIdxRef set
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
plot.over.addEventListener('mouseleave', () => {
|
plot.over.onmouseleave = () => {
|
||||||
const p = plotRef.current;
|
const p = plotRef.current;
|
||||||
if (!p) return;
|
if (!p) return;
|
||||||
p.setCursor({ left: idxToPixel(p, lastIdxRef.current), top: -10 });
|
p.setCursor({ left: idxToPixel(p, lastIdxRef.current), top: -10 });
|
||||||
});
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// deps is intentionally dynamic — passed by parent to allow external rebuild triggers
|
// deps is intentionally dynamic — passed by parent to allow external rebuild triggers
|
||||||
|
|||||||
Reference in New Issue
Block a user