@spider-analyzer/timeline 5.0.5 → 5.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/index.js +5 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/TimeLine.tsx +17 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spider-analyzer/timeline",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.6",
|
|
4
4
|
"description": "React graphical component to display metric over time with a time selection feature.",
|
|
5
5
|
"author": "Thibaut Raballand <spider.analyzer@gmail.com> (https://spider-analyzer.io)",
|
|
6
6
|
"license": "MIT",
|
package/src/TimeLine.tsx
CHANGED
|
@@ -207,7 +207,13 @@ const TimeLineInner = forwardRef<TimeLineHandle, any>(function TimeLine(props, r
|
|
|
207
207
|
|
|
208
208
|
patchState({ histoWidth, isActive: true, ticks });
|
|
209
209
|
|
|
210
|
-
|
|
210
|
+
// Gate the fetch on a usable histoWidth. Before the first valid
|
|
211
|
+
// width is measured (React mount, ResizeObserver, consumer layout)
|
|
212
|
+
// histoWidth can be <= 0 — in that case we'd otherwise hit the
|
|
213
|
+
// domainSpan/1 fallback and ask the backend for smallestResolution
|
|
214
|
+
// / tickCount=1 granularity over the whole domain. Wait for the
|
|
215
|
+
// width-change effect to re-run getItems with a real width.
|
|
216
|
+
if (shouldReload && intervalMs && histoWidth > 0) {
|
|
211
217
|
widthOfLastUpdateRef.current = p.width;
|
|
212
218
|
patchState({ waitForLoad: true });
|
|
213
219
|
p.onLoadHisto(intervalMs, domain.min, domain.max);
|
|
@@ -247,14 +253,19 @@ const TimeLineInner = forwardRef<TimeLineHandle, any>(function TimeLine(props, r
|
|
|
247
253
|
return;
|
|
248
254
|
}
|
|
249
255
|
const s = stateRef.current;
|
|
250
|
-
|
|
256
|
+
patchState(computeMarginAndWidth(props));
|
|
257
|
+
// Re-run getItems whenever width/margin changes AND we have a
|
|
258
|
+
// domain. Was previously guarded on s.isActive which meant the
|
|
259
|
+
// first getItems call (with an as-yet unknown width) locked us
|
|
260
|
+
// into a bad intervalMs: it set isActive=true but skipped the
|
|
261
|
+
// fetch (histoWidth <= 0 gate), and this effect wouldn't re-fetch
|
|
262
|
+
// because isActive was now true but big=false.
|
|
263
|
+
if (s.domain) {
|
|
251
264
|
const big =
|
|
252
265
|
widthOfLastUpdateRef.current !== null
|
|
253
266
|
&& Math.abs((props.width ?? 0) - (widthOfLastUpdateRef.current ?? 0)) > 30;
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
} else {
|
|
257
|
-
patchState(computeMarginAndWidth(props));
|
|
267
|
+
const shouldReload = !s.isActive || big || widthOfLastUpdateRef.current === null;
|
|
268
|
+
getItems(props, s.domain, shouldReload);
|
|
258
269
|
}
|
|
259
270
|
|
|
260
271
|
if (stateRef.current.domain) {
|