@spider-analyzer/timeline 5.0.3 → 5.0.4
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 +45 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/TimeLine.tsx +57 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spider-analyzer/timeline",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.4",
|
|
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
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
useCallback,
|
|
4
4
|
useEffect,
|
|
5
5
|
useImperativeHandle,
|
|
6
|
+
useMemo,
|
|
6
7
|
useRef,
|
|
7
8
|
useState,
|
|
8
9
|
} from 'react';
|
|
@@ -887,27 +888,66 @@ const TimeLine = forwardRef<TimeLineHandle, any>(function TimeLineWrapper(props,
|
|
|
887
888
|
else if (ret) apply(ret);
|
|
888
889
|
}, [props.onLoadDefaultDomain, props.onDomainChange, zone]);
|
|
889
890
|
|
|
890
|
-
//
|
|
891
|
-
//
|
|
892
|
-
// (
|
|
893
|
-
//
|
|
891
|
+
// Normalize incoming props into moment-typed values the inner expects.
|
|
892
|
+
// MEMOIZE on the raw consumer reference so that a parent re-render
|
|
893
|
+
// with an unchanged `histo` (etc.) doesn't hand the inner a fresh
|
|
894
|
+
// object — otherwise the inner's `histo !== prev` effect fires every
|
|
895
|
+
// render → setState → re-render → infinite loop (observed in
|
|
896
|
+
// Network-View: x-axis never stabilizes, loader never clears).
|
|
897
|
+
const timeSpanMoments = useMemo(
|
|
898
|
+
() => (props.timeSpan ? timeSpanToMoments(props.timeSpan, zone) : undefined),
|
|
899
|
+
[props.timeSpan, zone],
|
|
900
|
+
);
|
|
901
|
+
const maxDomainMoments = useMemo(
|
|
902
|
+
() => (props.maxDomain ? domainToMoments(props.maxDomain, zone) : undefined),
|
|
903
|
+
[props.maxDomain, zone],
|
|
904
|
+
);
|
|
905
|
+
const histoMoments = useMemo(
|
|
906
|
+
() => (props.histo?.items
|
|
907
|
+
? { ...props.histo, items: props.histo.items.map((it: any) => ({ ...it, time: toMoment(it.time, zone) })) }
|
|
908
|
+
: props.histo),
|
|
909
|
+
[props.histo, zone],
|
|
910
|
+
);
|
|
911
|
+
const qualityMoments = useMemo(
|
|
912
|
+
() => (props.quality?.items
|
|
913
|
+
? { ...props.quality, items: props.quality.items.map((it: any) => ({ ...it, time: toMoment(it.time, zone) })) }
|
|
914
|
+
: props.quality),
|
|
915
|
+
[props.quality, zone],
|
|
916
|
+
);
|
|
917
|
+
const biggestVisibleDomainDur = useMemo(
|
|
918
|
+
() => (props.biggestVisibleDomain != null ? toDuration(props.biggestVisibleDomain) : undefined),
|
|
919
|
+
[props.biggestVisibleDomain],
|
|
920
|
+
);
|
|
921
|
+
const biggestTimeSpanDur = useMemo(
|
|
922
|
+
() => (props.biggestTimeSpan != null ? toDuration(props.biggestTimeSpan) : undefined),
|
|
923
|
+
[props.biggestTimeSpan],
|
|
924
|
+
);
|
|
925
|
+
const smallestResolutionDur = useMemo(
|
|
926
|
+
() => (props.smallestResolution != null ? toDuration(props.smallestResolution) : undefined),
|
|
927
|
+
[props.smallestResolution],
|
|
928
|
+
);
|
|
929
|
+
const xAxisMerged = useMemo(
|
|
930
|
+
() => ({ ...xAxisDefault, ...(props.xAxis ?? {}) }),
|
|
931
|
+
[props.xAxis],
|
|
932
|
+
);
|
|
933
|
+
const marginMerged = useMemo(
|
|
934
|
+
() => ({ ...marginDefault, ...(props.margin ?? {}) }),
|
|
935
|
+
[props.margin],
|
|
936
|
+
);
|
|
937
|
+
|
|
894
938
|
const innerProps: any = {
|
|
895
939
|
...props,
|
|
896
|
-
xAxis:
|
|
940
|
+
xAxis: xAxisMerged,
|
|
897
941
|
yAxis: props.yAxis ?? {},
|
|
898
|
-
margin:
|
|
942
|
+
margin: marginMerged,
|
|
899
943
|
domains: stack,
|
|
900
|
-
timeSpan:
|
|
901
|
-
maxDomain:
|
|
902
|
-
histo:
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
: props.quality,
|
|
908
|
-
biggestVisibleDomain: props.biggestVisibleDomain != null ? toDuration(props.biggestVisibleDomain) : undefined,
|
|
909
|
-
biggestTimeSpan: props.biggestTimeSpan != null ? toDuration(props.biggestTimeSpan) : undefined,
|
|
910
|
-
smallestResolution: props.smallestResolution != null ? toDuration(props.smallestResolution) : undefined,
|
|
944
|
+
timeSpan: timeSpanMoments,
|
|
945
|
+
maxDomain: maxDomainMoments,
|
|
946
|
+
histo: histoMoments,
|
|
947
|
+
quality: qualityMoments,
|
|
948
|
+
biggestVisibleDomain: biggestVisibleDomainDur,
|
|
949
|
+
biggestTimeSpan: biggestTimeSpanDur,
|
|
950
|
+
smallestResolution: smallestResolutionDur,
|
|
911
951
|
onUpdateDomains: handleUpdateDomains,
|
|
912
952
|
onLoadDefaultDomain: handleLoadDefault,
|
|
913
953
|
// onLoadHisto: object shape + Date instants
|