@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/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { forwardRef, useRef, useEffect, useState, useCallback, useImperativeHandle } from 'react';
|
|
1
|
+
import { forwardRef, useRef, useEffect, useState, useCallback, useImperativeHandle, useMemo } from 'react';
|
|
2
2
|
import { DateTime, Duration } from 'luxon';
|
|
3
3
|
import { scaleLinear, scaleTime } from 'd3-scale';
|
|
4
4
|
import PropTypes11 from 'prop-types';
|
|
@@ -2071,9 +2071,11 @@ var TimeLineInner = forwardRef(function TimeLine(props, ref) {
|
|
|
2071
2071
|
const xAxis = scaleTime().domain([domain2.min, domain2.max]).range([0, histoWidth2]);
|
|
2072
2072
|
xAxis.clamp(true);
|
|
2073
2073
|
xAxisRef.current = xAxis;
|
|
2074
|
-
const
|
|
2074
|
+
const tickCount = floor(histoWidth2 / p.xAxis.spaceBetweenTicks);
|
|
2075
|
+
const ticks2 = xAxis.ticks(tickCount);
|
|
2076
|
+
const tickIntervalMs = ticks2.length >= 2 ? ticks2[1].getTime() - ticks2[0].getTime() : (+domain2.max - +domain2.min) / Math.max(tickCount, 1);
|
|
2075
2077
|
const intervalMs = max([
|
|
2076
|
-
round(
|
|
2078
|
+
round(tickIntervalMs / p.xAxis.barsBetweenTicks),
|
|
2077
2079
|
propsRef.current.smallestResolution.asMilliseconds()
|
|
2078
2080
|
]);
|
|
2079
2081
|
patchState({ histoWidth: histoWidth2, isActive: true, ticks: ticks2 });
|
|
@@ -2763,19 +2765,55 @@ var TimeLine2 = forwardRef(function TimeLineWrapper(props, ref) {
|
|
|
2763
2765
|
if (ret && typeof ret.then === "function") ret.then(apply);
|
|
2764
2766
|
else if (ret) apply(ret);
|
|
2765
2767
|
}, [props.onLoadDefaultDomain, props.onDomainChange, zone]);
|
|
2768
|
+
const timeSpanMoments = useMemo(
|
|
2769
|
+
() => props.timeSpan ? timeSpanToMoments(props.timeSpan, zone) : void 0,
|
|
2770
|
+
[props.timeSpan, zone]
|
|
2771
|
+
);
|
|
2772
|
+
const maxDomainMoments = useMemo(
|
|
2773
|
+
() => props.maxDomain ? domainToMoments(props.maxDomain, zone) : void 0,
|
|
2774
|
+
[props.maxDomain, zone]
|
|
2775
|
+
);
|
|
2776
|
+
const histoMoments = useMemo(
|
|
2777
|
+
() => props.histo?.items ? { ...props.histo, items: props.histo.items.map((it) => ({ ...it, time: toMoment(it.time, zone) })) } : props.histo,
|
|
2778
|
+
[props.histo, zone]
|
|
2779
|
+
);
|
|
2780
|
+
const qualityMoments = useMemo(
|
|
2781
|
+
() => props.quality?.items ? { ...props.quality, items: props.quality.items.map((it) => ({ ...it, time: toMoment(it.time, zone) })) } : props.quality,
|
|
2782
|
+
[props.quality, zone]
|
|
2783
|
+
);
|
|
2784
|
+
const biggestVisibleDomainDur = useMemo(
|
|
2785
|
+
() => props.biggestVisibleDomain != null ? toDuration(props.biggestVisibleDomain) : void 0,
|
|
2786
|
+
[props.biggestVisibleDomain]
|
|
2787
|
+
);
|
|
2788
|
+
const biggestTimeSpanDur = useMemo(
|
|
2789
|
+
() => props.biggestTimeSpan != null ? toDuration(props.biggestTimeSpan) : void 0,
|
|
2790
|
+
[props.biggestTimeSpan]
|
|
2791
|
+
);
|
|
2792
|
+
const smallestResolutionDur = useMemo(
|
|
2793
|
+
() => props.smallestResolution != null ? toDuration(props.smallestResolution) : void 0,
|
|
2794
|
+
[props.smallestResolution]
|
|
2795
|
+
);
|
|
2796
|
+
const xAxisMerged = useMemo(
|
|
2797
|
+
() => ({ ...xAxisDefault, ...props.xAxis ?? {} }),
|
|
2798
|
+
[props.xAxis]
|
|
2799
|
+
);
|
|
2800
|
+
const marginMerged = useMemo(
|
|
2801
|
+
() => ({ ...marginDefault, ...props.margin ?? {} }),
|
|
2802
|
+
[props.margin]
|
|
2803
|
+
);
|
|
2766
2804
|
const innerProps = {
|
|
2767
2805
|
...props,
|
|
2768
|
-
xAxis:
|
|
2806
|
+
xAxis: xAxisMerged,
|
|
2769
2807
|
yAxis: props.yAxis ?? {},
|
|
2770
|
-
margin:
|
|
2808
|
+
margin: marginMerged,
|
|
2771
2809
|
domains: stack,
|
|
2772
|
-
timeSpan:
|
|
2773
|
-
maxDomain:
|
|
2774
|
-
histo:
|
|
2775
|
-
quality:
|
|
2776
|
-
biggestVisibleDomain:
|
|
2777
|
-
biggestTimeSpan:
|
|
2778
|
-
smallestResolution:
|
|
2810
|
+
timeSpan: timeSpanMoments,
|
|
2811
|
+
maxDomain: maxDomainMoments,
|
|
2812
|
+
histo: histoMoments,
|
|
2813
|
+
quality: qualityMoments,
|
|
2814
|
+
biggestVisibleDomain: biggestVisibleDomainDur,
|
|
2815
|
+
biggestTimeSpan: biggestTimeSpanDur,
|
|
2816
|
+
smallestResolution: smallestResolutionDur,
|
|
2779
2817
|
onUpdateDomains: handleUpdateDomains,
|
|
2780
2818
|
onLoadDefaultDomain: handleLoadDefault,
|
|
2781
2819
|
// onLoadHisto: object shape + Date instants
|