Skip to content

Commit fb5e29b

Browse files
pr feedback
1 parent 17a6c9b commit fb5e29b

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

src/features/Overview/LiveNetworkMetrics/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ function TableRow({
124124
<Table.Cell className={styles.chart}>
125125
<TileSparkLine
126126
value={Math.min(1, emaValue / maxValue)}
127-
includeBg={false}
127+
background="#0000001F"
128128
windowMs={60_000}
129129
height={chartHeight}
130130
updateIntervalMs={500}

src/features/Overview/LiveTileMetrics/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ const MUtilization = memo(function Utilization({ idx }: UtilizationProps) {
225225
<Table.Cell className={styles.noPadding}>
226226
<TileSparkLine
227227
value={avgValue}
228-
includeBg={false}
228+
background="#0000001F"
229229
windowMs={60_000}
230230
height={chartHeight}
231231
updateIntervalMs={updateIntervalMs}

src/features/Overview/SlotPerformance/useTileSparkline.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,12 @@ interface PointSample {
7474
ts: number;
7575
}
7676

77-
let tickMs = 150;
77+
const defaultTickMs = 150;
7878
/** How many ticks of extra buffer data is drawn for the transform to slide over */
7979
const tickBufferCount = 3;
8080

81-
const clock = clockSub(tickMs);
82-
83-
function setTickMs(newTickMs?: number) {
84-
if (newTickMs === undefined) return;
85-
tickMs = newTickMs;
86-
clock.startChartClock(newTickMs);
87-
}
81+
const clocks = new Map<number, ReturnType<typeof clockSub>>();
82+
clocks.set(defaultTickMs, clockSub(defaultTickMs));
8883

8984
function setDataWindow(
9085
data: (PointSample | undefined)[],
@@ -122,14 +117,12 @@ export function useScaledDataPoints({
122117
width: _width,
123118
updateIntervalMs,
124119
stopShifting,
125-
tickMs: _tickMs,
120+
tickMs = defaultTickMs,
126121
}: UseScaledDataPointsProps) {
127122
const [scaledDataPoints, setScaledDataPoints] = useState<
128123
{ x: number; y: number }[]
129124
>([]);
130125

131-
useEffect(() => setTickMs(_tickMs), [_tickMs]);
132-
133126
const { pxPerTick, width, windowMs } = useMemo(() => {
134127
let windowMs = _windowMs;
135128
let width = _width;
@@ -144,7 +137,7 @@ export function useScaledDataPoints({
144137
width,
145138
windowMs,
146139
};
147-
}, [_width, _windowMs, queryBusy]);
140+
}, [_width, _windowMs, queryBusy, tickMs]);
148141

149142
const busyDataRef = useRef([
150143
{ value: undefined, ts: performance.now() - windowMs },
@@ -222,13 +215,19 @@ export function useScaledDataPoints({
222215
}
223216
// live
224217
else {
225-
const unsub = clock.subscribeClock((tEnd) => {
226-
tick(busyDataRef.current, tEnd);
227-
});
218+
if (!clocks.has(tickMs)) {
219+
clocks.set(tickMs, clockSub(tickMs));
220+
}
221+
const clock = clocks.get(tickMs);
222+
if (clock) {
223+
const unsub = clock.subscribeClock((tEnd) => {
224+
tick(busyDataRef.current, tEnd);
225+
});
228226

229-
return unsub;
227+
return unsub;
228+
}
230229
}
231-
}, [height, queryBusy, width, windowMs]);
230+
}, [height, queryBusy, tickMs, width, windowMs]);
232231

233232
return {
234233
scaledDataPoints,

0 commit comments

Comments
 (0)