@spider-analyzer/timeline 5.0.4 → 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 +29 -0
- package/dist/index.js +9 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/TimeLine.tsx +29 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
## 5.0.6
|
|
2
|
+
|
|
3
|
+
- Fix: don't issue the first `onLoadHisto` with a stale `intervalMs`
|
|
4
|
+
when the consumer hasn't measured a valid width yet. `getItems` now
|
|
5
|
+
short-circuits the fetch while `histoWidth <= 0`, and the width-change
|
|
6
|
+
effect re-runs `getItems` whenever a domain exists (not only when the
|
|
7
|
+
prior call marked `isActive=true`). Previously the first call fired
|
|
8
|
+
with `histoWidth=0`, fell back to `domainSpan / 1 tick` and divided by
|
|
9
|
+
`barsBetweenTicks` — giving a coarse interval like 3 h over a 24 h
|
|
10
|
+
window; the subsequent width arrival then never retriggered the load
|
|
11
|
+
because `isActive` was already true and the delta check failed.
|
|
12
|
+
|
|
13
|
+
## 5.0.5
|
|
14
|
+
|
|
15
|
+
- Fix: compute intervalMs defensively in `getItems`. When d3's
|
|
16
|
+
`xAxis.ticks(N)` momentarily returned fewer than 2 entries (sparse
|
|
17
|
+
tick generation during the first render, while layout is still
|
|
18
|
+
settling), the previous code did `moment(ticks[1]).diff(moment(ticks[0]))`
|
|
19
|
+
with `ticks[1]` undefined. `moment(undefined)` is "now", so the diff
|
|
20
|
+
went negative, `_max` picked `smallestResolution`, and the very first
|
|
21
|
+
`onLoadHisto` asked for a 15 ms resolution over the whole domain —
|
|
22
|
+
flooding the backend. Any subsequent gesture (scroll, resize) produced
|
|
23
|
+
a correct interval, matching the user-observed "scrolling fixes it"
|
|
24
|
+
behavior.
|
|
25
|
+
|
|
26
|
+
Fix: when ticks are sparse, fall back to `domainSpan / tickCount`
|
|
27
|
+
instead of trusting ticks[1]−ticks[0]. Same nice-interval behavior on
|
|
28
|
+
the happy path, no regression when d3 hasn't produced enough ticks.
|
|
29
|
+
|
|
1
30
|
## 5.0.4
|
|
2
31
|
|
|
3
32
|
- Fix: memoize the moment-typed props built by the outer TimeLine
|
package/dist/index.js
CHANGED
|
@@ -2081,13 +2081,15 @@ var TimeLineInner = react.forwardRef(function TimeLine(props, ref) {
|
|
|
2081
2081
|
const xAxis = d3Scale.scaleTime().domain([domain2.min, domain2.max]).range([0, histoWidth2]);
|
|
2082
2082
|
xAxis.clamp(true);
|
|
2083
2083
|
xAxisRef.current = xAxis;
|
|
2084
|
-
const
|
|
2084
|
+
const tickCount = floor(histoWidth2 / p.xAxis.spaceBetweenTicks);
|
|
2085
|
+
const ticks2 = xAxis.ticks(tickCount);
|
|
2086
|
+
const tickIntervalMs = ticks2.length >= 2 ? ticks2[1].getTime() - ticks2[0].getTime() : (+domain2.max - +domain2.min) / Math.max(tickCount, 1);
|
|
2085
2087
|
const intervalMs = max([
|
|
2086
|
-
round(
|
|
2088
|
+
round(tickIntervalMs / p.xAxis.barsBetweenTicks),
|
|
2087
2089
|
propsRef.current.smallestResolution.asMilliseconds()
|
|
2088
2090
|
]);
|
|
2089
2091
|
patchState({ histoWidth: histoWidth2, isActive: true, ticks: ticks2 });
|
|
2090
|
-
if (shouldReload && intervalMs) {
|
|
2092
|
+
if (shouldReload && intervalMs && histoWidth2 > 0) {
|
|
2091
2093
|
widthOfLastUpdateRef.current = p.width;
|
|
2092
2094
|
patchState({ waitForLoad: true });
|
|
2093
2095
|
p.onLoadHisto(intervalMs, domain2.min, domain2.max);
|
|
@@ -2117,12 +2119,11 @@ var TimeLineInner = react.forwardRef(function TimeLine(props, ref) {
|
|
|
2117
2119
|
return;
|
|
2118
2120
|
}
|
|
2119
2121
|
const s = stateRef.current;
|
|
2120
|
-
|
|
2122
|
+
patchState(computeMarginAndWidth(props));
|
|
2123
|
+
if (s.domain) {
|
|
2121
2124
|
const big = widthOfLastUpdateRef.current !== null && Math.abs((props.width ?? 0) - (widthOfLastUpdateRef.current ?? 0)) > 30;
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
} else {
|
|
2125
|
-
patchState(computeMarginAndWidth(props));
|
|
2125
|
+
const shouldReload = !s.isActive || big || widthOfLastUpdateRef.current === null;
|
|
2126
|
+
getItems(props, s.domain, shouldReload);
|
|
2126
2127
|
}
|
|
2127
2128
|
if (stateRef.current.domain) {
|
|
2128
2129
|
const res = checkAndCorrectDomain({ domain: stateRef.current.domain });
|