Compare commits
1 Commits
1-max-seri
...
2-mouselea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c754316935 |
@@ -50,7 +50,7 @@ export default function SignalsChart({
|
||||
|
||||
const { containerRef, legendRef } = usePlot(
|
||||
(el, w, h, lRef) => {
|
||||
const data = buildSeriesData(rows, config.signal_type, timeMode, config.series_limit);
|
||||
const data = buildSeriesData(rows, config.signal_type, timeMode);
|
||||
if (!data) return null;
|
||||
|
||||
const { keys, allXs, data: seriesData } = data;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import type { SignalRow, ChartConfig, TimeMode } from '@/lib/types';
|
||||
|
||||
const MAX_SERIES = 80;
|
||||
|
||||
export interface SeriesData {
|
||||
keys: string[];
|
||||
allXs: number[];
|
||||
@@ -10,7 +12,6 @@ export function buildSeriesData(
|
||||
rows: SignalRow[],
|
||||
signalType: ChartConfig['signal_type'],
|
||||
timeMode: TimeMode,
|
||||
seriesLimit: number = 80,
|
||||
): SeriesData | null {
|
||||
const seriesMap = new Map<string, Map<number, number>>();
|
||||
|
||||
@@ -33,7 +34,7 @@ export function buildSeriesData(
|
||||
|
||||
if (seriesMap.size === 0) return null;
|
||||
|
||||
const keys = [...seriesMap.keys()].slice(0, seriesLimit);
|
||||
const keys = [...seriesMap.keys()].slice(0, MAX_SERIES);
|
||||
const allXs = [
|
||||
...new Set(
|
||||
keys.flatMap((k) => {
|
||||
|
||||
@@ -57,11 +57,11 @@ export function usePlot(
|
||||
|
||||
// Defer mouseleave — prevents React hydration events firing before lastIdxRef set
|
||||
requestAnimationFrame(() => {
|
||||
plot.over.addEventListener('mouseleave', () => {
|
||||
plot.over.onmouseleave = () => {
|
||||
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