@spider-analyzer/timeline 5.0.3 → 5.0.5
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 +49 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +50 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/TimeLine.tsx +69 -19
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
## 5.0.5
|
|
2
|
+
|
|
3
|
+
- Fix: compute intervalMs defensively in `getItems`. When d3's
|
|
4
|
+
`xAxis.ticks(N)` momentarily returned fewer than 2 entries (sparse
|
|
5
|
+
tick generation during the first render, while layout is still
|
|
6
|
+
settling), the previous code did `moment(ticks[1]).diff(moment(ticks[0]))`
|
|
7
|
+
with `ticks[1]` undefined. `moment(undefined)` is "now", so the diff
|
|
8
|
+
went negative, `_max` picked `smallestResolution`, and the very first
|
|
9
|
+
`onLoadHisto` asked for a 15 ms resolution over the whole domain —
|
|
10
|
+
flooding the backend. Any subsequent gesture (scroll, resize) produced
|
|
11
|
+
a correct interval, matching the user-observed "scrolling fixes it"
|
|
12
|
+
behavior.
|
|
13
|
+
|
|
14
|
+
Fix: when ticks are sparse, fall back to `domainSpan / tickCount`
|
|
15
|
+
instead of trusting ticks[1]−ticks[0]. Same nice-interval behavior on
|
|
16
|
+
the happy path, no regression when d3 hasn't produced enough ticks.
|
|
17
|
+
|
|
18
|
+
## 5.0.4
|
|
19
|
+
|
|
20
|
+
- Fix: memoize the moment-typed props built by the outer TimeLine
|
|
21
|
+
wrapper. Previously `histo`, `quality`, `timeSpan`, `maxDomain`,
|
|
22
|
+
duration props, and the xAxis/margin defaults were rebuilt on every
|
|
23
|
+
wrapper render. The inner component's "did this reference change?"
|
|
24
|
+
effects (`histo !== prevHisto`, width/margin, etc.) fired on every
|
|
25
|
+
render, each calling `setState` and forcing another render — an
|
|
26
|
+
infinite loop that pegged CPU, kept the loader visible forever, and
|
|
27
|
+
left the x-axis ticks empty. Stabilizing the references with
|
|
28
|
+
`useMemo` (keyed on the raw consumer references) breaks the loop.
|
|
29
|
+
|
|
1
30
|
## 5.0.3
|
|
2
31
|
|
|
3
32
|
- Fix: preserve `undefined` at the Date-→-Moment boundary. Optional
|
package/dist/index.js
CHANGED
|
@@ -2081,9 +2081,11 @@ 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 });
|
|
@@ -2773,19 +2775,55 @@ var TimeLine2 = react.forwardRef(function TimeLineWrapper(props, ref) {
|
|
|
2773
2775
|
if (ret && typeof ret.then === "function") ret.then(apply);
|
|
2774
2776
|
else if (ret) apply(ret);
|
|
2775
2777
|
}, [props.onLoadDefaultDomain, props.onDomainChange, zone]);
|
|
2778
|
+
const timeSpanMoments = react.useMemo(
|
|
2779
|
+
() => props.timeSpan ? timeSpanToMoments(props.timeSpan, zone) : void 0,
|
|
2780
|
+
[props.timeSpan, zone]
|
|
2781
|
+
);
|
|
2782
|
+
const maxDomainMoments = react.useMemo(
|
|
2783
|
+
() => props.maxDomain ? domainToMoments(props.maxDomain, zone) : void 0,
|
|
2784
|
+
[props.maxDomain, zone]
|
|
2785
|
+
);
|
|
2786
|
+
const histoMoments = react.useMemo(
|
|
2787
|
+
() => props.histo?.items ? { ...props.histo, items: props.histo.items.map((it) => ({ ...it, time: toMoment(it.time, zone) })) } : props.histo,
|
|
2788
|
+
[props.histo, zone]
|
|
2789
|
+
);
|
|
2790
|
+
const qualityMoments = react.useMemo(
|
|
2791
|
+
() => props.quality?.items ? { ...props.quality, items: props.quality.items.map((it) => ({ ...it, time: toMoment(it.time, zone) })) } : props.quality,
|
|
2792
|
+
[props.quality, zone]
|
|
2793
|
+
);
|
|
2794
|
+
const biggestVisibleDomainDur = react.useMemo(
|
|
2795
|
+
() => props.biggestVisibleDomain != null ? toDuration(props.biggestVisibleDomain) : void 0,
|
|
2796
|
+
[props.biggestVisibleDomain]
|
|
2797
|
+
);
|
|
2798
|
+
const biggestTimeSpanDur = react.useMemo(
|
|
2799
|
+
() => props.biggestTimeSpan != null ? toDuration(props.biggestTimeSpan) : void 0,
|
|
2800
|
+
[props.biggestTimeSpan]
|
|
2801
|
+
);
|
|
2802
|
+
const smallestResolutionDur = react.useMemo(
|
|
2803
|
+
() => props.smallestResolution != null ? toDuration(props.smallestResolution) : void 0,
|
|
2804
|
+
[props.smallestResolution]
|
|
2805
|
+
);
|
|
2806
|
+
const xAxisMerged = react.useMemo(
|
|
2807
|
+
() => ({ ...xAxisDefault, ...props.xAxis ?? {} }),
|
|
2808
|
+
[props.xAxis]
|
|
2809
|
+
);
|
|
2810
|
+
const marginMerged = react.useMemo(
|
|
2811
|
+
() => ({ ...marginDefault, ...props.margin ?? {} }),
|
|
2812
|
+
[props.margin]
|
|
2813
|
+
);
|
|
2776
2814
|
const innerProps = {
|
|
2777
2815
|
...props,
|
|
2778
|
-
xAxis:
|
|
2816
|
+
xAxis: xAxisMerged,
|
|
2779
2817
|
yAxis: props.yAxis ?? {},
|
|
2780
|
-
margin:
|
|
2818
|
+
margin: marginMerged,
|
|
2781
2819
|
domains: stack,
|
|
2782
|
-
timeSpan:
|
|
2783
|
-
maxDomain:
|
|
2784
|
-
histo:
|
|
2785
|
-
quality:
|
|
2786
|
-
biggestVisibleDomain:
|
|
2787
|
-
biggestTimeSpan:
|
|
2788
|
-
smallestResolution:
|
|
2820
|
+
timeSpan: timeSpanMoments,
|
|
2821
|
+
maxDomain: maxDomainMoments,
|
|
2822
|
+
histo: histoMoments,
|
|
2823
|
+
quality: qualityMoments,
|
|
2824
|
+
biggestVisibleDomain: biggestVisibleDomainDur,
|
|
2825
|
+
biggestTimeSpan: biggestTimeSpanDur,
|
|
2826
|
+
smallestResolution: smallestResolutionDur,
|
|
2789
2827
|
onUpdateDomains: handleUpdateDomains,
|
|
2790
2828
|
onLoadDefaultDomain: handleLoadDefault,
|
|
2791
2829
|
// onLoadHisto: object shape + Date instants
|