@spider-analyzer/timeline 5.0.4 → 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 CHANGED
@@ -1,3 +1,20 @@
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
+
1
18
  ## 5.0.4
2
19
 
3
20
  - Fix: memoize the moment-typed props built by the outer TimeLine
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 ticks2 = xAxis.ticks(floor(histoWidth2 / p.xAxis.spaceBetweenTicks));
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(moment_shim_default(ticks2[1]).diff(moment_shim_default(ticks2[0])) / p.xAxis.barsBetweenTicks),
2088
+ round(tickIntervalMs / p.xAxis.barsBetweenTicks),
2087
2089
  propsRef.current.smallestResolution.asMilliseconds()
2088
2090
  ]);
2089
2091
  patchState({ histoWidth: histoWidth2, isActive: true, ticks: ticks2 });