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