react-native-livechart 4.30.1 → 4.30.2

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.
@@ -2,10 +2,9 @@ import { type SharedValue } from "react-native-reanimated";
2
2
  import type { ResolvedDotGlowConfig, ResolvedDotRingConfig, ResolvedPulseConfig } from "../core/resolveConfig";
3
3
  import type { LiveChartPalette } from "../types";
4
4
  /**
5
- * Quantizes the pulse clock to visible radius changes and parks it while the
6
- * pulse is fully transparent.
5
+ * Advances on every visible display frame and parks while fully transparent.
7
6
  */
8
- export declare function quantizePulseClock(timestamp: number, interval: number, duration: number, maxRadius: number): number;
7
+ export declare function pulseClockTime(timestamp: number, interval: number, duration: number, maxRadius: number): number;
9
8
  /**
10
9
  * Live dot + expanding pulse ring. The dot is a color-filled circle of `radius`
11
10
  * with an optional contrasting outer `ring` (halo). Peak pulse size uses
@@ -1 +1 @@
1
- {"version":3,"file":"DotOverlay.d.ts","sourceRoot":"","sources":["../../src/components/DotOverlay.tsx"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAKjD;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAChB,MAAM,CAcR;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,EACzB,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,KAAK,EACL,IAAW,EACX,MAAM,EACN,IAAI,EACJ,KAAK,EACL,OAAO,EACP,gBAAwB,EACxB,iBAAiB,GAClB,EAAE;IACD,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,C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M,CAAC;IAClB,kEAAkE;IAClE,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,KAAK,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAClC,8EAA8E;IAC9E,OAAO,CAAC,EAAE,WAAW,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACrC,4CAA4C;IAC5C,WAAW,EAAE,MAAM,CAAC;CACrB,+BAgCA"}
package/package.json CHANGED
@@ -67,5 +67,5 @@
67
67
  },
68
68
  "sideEffects": false,
69
69
  "types": "./dist/index.d.ts",
70
- "version": "4.30.1"
70
+ "version": "4.30.2"
71
71
  }
@@ -14,13 +14,11 @@ import type {
14
14
  import type { LiveChartPalette } from "../types";
15
15
 
16
16
  const MIN_PULSE_RADIUS = 9;
17
- const PULSE_PIXEL_STEP = 0.5;
18
17
 
19
18
  /**
20
- * Quantizes the pulse clock to visible radius changes and parks it while the
21
- * pulse is fully transparent.
19
+ * Advances on every visible display frame and parks while fully transparent.
22
20
  */
23
- export function quantizePulseClock(
21
+ export function pulseClockTime(
24
22
  timestamp: number,
25
23
  interval: number,
26
24
  duration: number,
@@ -33,12 +31,7 @@ export function quantizePulseClock(
33
31
 
34
32
  const radiusTravel = maxRadius - MIN_PULSE_RADIUS;
35
33
  if (!(radiusTravel > 0) || !(duration > 0)) return cycleStart;
36
- const millisecondsPerStep =
37
- (duration * PULSE_PIXEL_STEP) / radiusTravel;
38
- return (
39
- cycleStart +
40
- Math.floor(elapsed / millisecondsPerStep) * millisecondsPerStep
41
- );
34
+ return timestamp;
42
35
  }
43
36
 
44
37
  /**
@@ -97,7 +90,7 @@ export function DotOverlay({
97
90
  /* istanbul ignore next -- frame-callback worklet runs on the UI thread, not in Jest */
98
91
  const pulseClock = useFrameCallback((frame) => {
99
92
  if (!pulse || isFrameLoopActive?.get() === false) return;
100
- pulseClockMs.value = quantizePulseClock(
93
+ pulseClockMs.value = pulseClockTime(
101
94
  frame.timestamp,
102
95
  pulse.interval,
103
96
  pulse.duration,
@@ -1,6 +1,12 @@
1
1
  import { BlurMask, Circle, Group } from "@shopify/react-native-skia";
2
2
 
3
- import { useDerivedValue, type SharedValue } from "react-native-reanimated";
3
+ import { useEffect } from "react";
4
+ import {
5
+ useDerivedValue,
6
+ useFrameCallback,
7
+ useSharedValue,
8
+ type SharedValue,
9
+ } from "react-native-reanimated";
4
10
  import { lineTipX, type ChartPadding } from "../draw/line";
5
11
  import type {
6
12
  ResolvedDotGlowConfig,
@@ -23,7 +29,9 @@ function SeriesDotAtIndex({
23
29
  ringColor,
24
30
  pulse,
25
31
  viewEnd,
32
+ pulseClockMs,
26
33
  }: {
34
+ pulseClockMs: SharedValue<number>;
27
35
  index: number;
28
36
  engine: MultiEngineState;
29
37
  padding: ChartPadding;
@@ -70,10 +78,9 @@ function SeriesDotAtIndex({
70
78
  });
71
79
 
72
80
  const pulseRadius = useDerivedValue(() => {
73
- // A live heartbeat on a frozen historical point is wrong (and `timestamp` is
74
- // frozen, so it wouldn't animate) — suppress the pulse while scrolled back.
81
+ // A live heartbeat would mislabel a frozen historical point.
75
82
  if (!pulse || viewEnd?.value != null) return 0;
76
- const nowMs = engine.timestamp.value * 1000 + index * PULSE_STAGGER_MS;
83
+ const nowMs = pulseClockMs.value + index * PULSE_STAGGER_MS;
77
84
  const t = (nowMs % pulse.interval) / pulse.duration;
78
85
  if (t >= 1) return 0;
79
86
  return MIN_PULSE_RADIUS + t * (pulse.maxRadius - MIN_PULSE_RADIUS);
@@ -81,7 +88,7 @@ function SeriesDotAtIndex({
81
88
 
82
89
  const pulseOpacity = useDerivedValue(() => {
83
90
  if (!pulse || viewEnd?.value != null) return 0;
84
- const nowMs = engine.timestamp.value * 1000 + index * PULSE_STAGGER_MS;
91
+ const nowMs = pulseClockMs.value + index * PULSE_STAGGER_MS;
85
92
  const t = (nowMs % pulse.interval) / pulse.duration;
86
93
  if (t >= 1) return 0;
87
94
  return pulse.opacity * (1 - t);
@@ -155,6 +162,17 @@ export function MultiSeriesDots({
155
162
  /** Number of live series slots to mount. */
156
163
  seriesCount: number;
157
164
  }) {
165
+ // Presentation time may advance only when a consumer publishes data. The
166
+ // decorative heartbeat must follow display frames independently of it.
167
+ const pulseClockMs = useSharedValue(0);
168
+ const pulseClock = useFrameCallback((frame) => {
169
+ if (!pulse || viewEnd?.get() != null) return;
170
+ pulseClockMs.value = frame.timestamp;
171
+ }, pulse != null);
172
+ useEffect(() => {
173
+ pulseClock.setActive(pulse != null);
174
+ }, [pulse, pulseClock]);
175
+
158
176
  return (
159
177
  <Group>
160
178
  {Array.from({ length: seriesCount }, (_, i) => (
@@ -170,6 +188,7 @@ export function MultiSeriesDots({
170
188
  ringColor={ringColor}
171
189
  pulse={pulse}
172
190
  viewEnd={viewEnd}
191
+ pulseClockMs={pulseClockMs}
173
192
  />
174
193
  ))}
175
194
  </Group>