@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 +17 -0
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/TimeLine.tsx +12 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spider-analyzer/timeline",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.5",
|
|
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
|
@@ -189,9 +189,19 @@ const TimeLineInner = forwardRef<TimeLineHandle, any>(function TimeLine(props, r
|
|
|
189
189
|
xAxis.clamp(true);
|
|
190
190
|
xAxisRef.current = xAxis;
|
|
191
191
|
|
|
192
|
-
const
|
|
192
|
+
const tickCount = _floor(histoWidth / p.xAxis.spaceBetweenTicks);
|
|
193
|
+
const ticks = xAxis.ticks(tickCount);
|
|
194
|
+
// intervalMs should be domainSpan/(visibleTickCount*barsBetweenTicks).
|
|
195
|
+
// Use ticks[1]-ticks[0] when d3 gives us >= 2 "nice" ticks (preserves
|
|
196
|
+
// the original intent of snapping to minute/hour-aligned intervals);
|
|
197
|
+
// otherwise fall back to domainSpan/tickCount so we never regress to
|
|
198
|
+
// smallestResolution on the very first render (when tick generation
|
|
199
|
+
// can be momentarily sparse).
|
|
200
|
+
const tickIntervalMs = ticks.length >= 2
|
|
201
|
+
? ticks[1].getTime() - ticks[0].getTime()
|
|
202
|
+
: (+domain.max - +domain.min) / Math.max(tickCount, 1);
|
|
193
203
|
const intervalMs = _max([
|
|
194
|
-
_round(
|
|
204
|
+
_round(tickIntervalMs / p.xAxis.barsBetweenTicks),
|
|
195
205
|
propsRef.current.smallestResolution.asMilliseconds(),
|
|
196
206
|
]) as number;
|
|
197
207
|
|