@wick-charts/react 0.3.2 → 0.3.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/dist/index.d.ts CHANGED
@@ -6,39 +6,67 @@ import { ReactNode } from 'react';
6
6
  export declare const andromeda: ThemePreset;
7
7
 
8
8
  /**
9
- * Chart-level animation configuration. Split into two independent domains so
10
- * per-series defaults can't bleed into viewport-interaction timings:
9
+ * Chart-level animation configuration. Two independent domains so per-series
10
+ * defaults can't bleed into viewport-interaction timings.
11
11
  *
12
- * - `points`animations applied to data: per-series entrance tween, live-
13
- * tracking smoothing of the last candle/bar/line value, pulse cadence.
14
- * These values act as defaults for each series. Per-series options always
15
- * win unless the chart-level category is explicitly `false`, in which case
16
- * the whole category is forced off.
12
+ * **Two layerschart-level vs per-series.** The same data-animation knobs
13
+ * live on both layers; remember which is which:
17
14
  *
18
- * - `viewport` animations applied to viewport interactions: post-gesture
19
- * rebound duration and Y-axis range smoothing.
15
+ * | Field | Chart-level (here) | Per-series option |
16
+ * | ----- | ------------------ | ----------------- |
17
+ * | Entry duration | {@link AnimationsConfig.points}`.enterMs` | `<XSeries options={{ entryMs }}>` (canonical name; `enterMs` is a `@deprecated` alias) |
18
+ * | Live smoothing | `points.smoothMs` | `options={{ smoothMs }}` |
19
+ * | Line pulse period | `points.pulseMs` | `<LineSeries options={{ pulseMs }}>` |
20
20
  *
21
- * User-initiated pan/zoom (wheel, drag, touch) always applies instantly. The
22
- * latency of an exponential chase reads as laggy in practice. API-driven
23
- * transitions (`fitToData`, `scrollToEnd`) and post-gesture rebound still
24
- * tween via their own fixed-duration ease-out.
21
+ * Resolution: per-series option **wins** (it's the override). The chart-
22
+ * level field acts as the default for every series that didn't set its own
23
+ * override *except* when the chart-level category is explicitly `false`,
24
+ * which is a hard disable that overrides per-series too.
25
+ *
26
+ * - `points` — applied to data: entrance tween, live-tracking smoothing of
27
+ * the last candle/bar/line value, line pulse cadence.
28
+ * - `viewport` — applied to viewport interactions: post-gesture rebound,
29
+ * Y-axis range chase, optional per-event ease for pan/zoom. Has no
30
+ * per-series equivalent — these are chart-level only.
31
+ *
32
+ * All settling animations share a 250 ms default so the X re-fit, Y range
33
+ * update, and last-bar live-track all settle on the same frame on a
34
+ * streaming tick. Pulse cycle period (600 ms) and `inputResponseMs` (0,
35
+ * opt-in) keep their own values.
25
36
  */
26
- declare interface AnimationsConfig {
37
+ export declare interface AnimationsConfig {
27
38
  /**
28
39
  * Data-series animations. `false` disables every point animation (entrance,
29
- * live-smoothing, pulse) across every series. An object overrides individual
30
- * categories; omitted fields fall back to the built-in defaults.
40
+ * live-smoothing, pulse) across every series overrides any per-series
41
+ * option set on the same fields. An object overrides individual categories;
42
+ * omitted fields fall back to the built-in defaults.
43
+ *
44
+ * Per-series options (`<LineSeries options={{ entryMs, smoothMs, pulseMs }}>`)
45
+ * win over chart-level numeric values. The chart-level field becomes the
46
+ * default for series that don't set their own.
31
47
  */
32
48
  points?: false | {
33
- /** Per-point entrance duration (ms). `false`/`0` disables. Default: 400. */
49
+ /**
50
+ * Per-point entrance duration (ms). Default: 250.
51
+ * Per-series equivalent: `<XSeries options={{ entryMs }}>` (note the
52
+ * `y` — chart-level uses `enterMs`, per-series uses `entryMs` for
53
+ * historical reasons; both refer to the same animation). `false` /
54
+ * `0` disables.
55
+ */
34
56
  enterMs?: AnimationTime;
35
57
  /**
36
- * Exponential-smoothing time constant (ms) for live last-value chase.
37
- * `false`/`0` disables smoothing the last point snaps to the target.
38
- * Default: 70 ms (equivalent to the legacy `liveSmoothRate = 14`).
58
+ * Live-value chase duration (ms) for the displayed last point on
59
+ * `updateData` ticks. Animator-driven cubic ease after this many ms
60
+ * with no new updates, the displayed value reaches exactly the
61
+ * actual last value. Default: 250. Per-series equivalent:
62
+ * `options={{ smoothMs }}`. `false` / `0` snaps.
39
63
  */
40
64
  smoothMs?: AnimationTime;
41
- /** Pulse cycle period (ms) for the line last-point halo. Default: 600. */
65
+ /**
66
+ * Pulse cycle period (ms) for the line last-point halo — periodic,
67
+ * not a one-shot transition. Default: 600. Per-series equivalent:
68
+ * `<LineSeries options={{ pulseMs }}>`. `false` / `0` disables.
69
+ */
42
70
  pulseMs?: AnimationTime;
43
71
  };
44
72
  /**
@@ -49,15 +77,33 @@ declare interface AnimationsConfig {
49
77
  /** Rebound (snap-back) duration after pan/zoom overshoot (ms). Default: 350. */
50
78
  reboundMs?: AnimationTime;
51
79
  /**
52
- * Y-axis range transition scale. **Frame-count-based, calibrated at
53
- * 60 Hz not wall-clock ms.** Each render frame closes
54
- * `min(1, 16 / yAxisMs)` of the remaining gap. Default 80 the
55
- * legacy 0.2-per-frame closure. `false` / `0` snaps the Y range
56
- * instantly. Unlike `smoothMs` / `entryMs` / `reboundMs`, the
57
- * perceptual duration scales with frame time on refresh rates far
58
- * from 60 Hz.
80
+ * Y-axis range transition duration in wall-clock milliseconds. The Y
81
+ * min and max each ride their own {@link Animator} that retargets on
82
+ * data updates and eases toward the new bound over this many ms.
83
+ * Default `250` (shares the lockstep-arrival budget with viewport and
84
+ * live-track). Inward contraction always eases. Outward expansion
85
+ * eases when the per-point entrance is enabled (the entering candle's
86
+ * fade masks the brief overshoot); when entrance is hard-disabled
87
+ * (`points.enterMs === 0`), Y bounds snap outward to keep new
88
+ * highs/lows from clipping at the canvas edge. `false` / `0` snaps
89
+ * the Y range instantly on every update.
59
90
  */
60
91
  yAxisMs?: AnimationTime;
92
+ /**
93
+ * Per-event ease applied to user pan/zoom commits. Logical state
94
+ * advances synchronously (gesture math, edge detection, autoscroll
95
+ * all read the committed target); the visual range eases over this
96
+ * duration so back-to-back wheel/trackpad events interpolate
97
+ * smoothly through the same animator.
98
+ *
99
+ * Default `0` (instant-apply, matches the long-standing pre-Phase-5
100
+ * behaviour). Opt in via `inputResponseMs: 60` for an eased pan/zoom
101
+ * feel — the default is conservative because the animated visual
102
+ * range diverges from the committed target until the ease completes,
103
+ * and existing consumers reading `chart.getVisibleRange()`
104
+ * synchronously after a wheel/pan expect the new value.
105
+ */
106
+ inputResponseMs?: AnimationTime;
61
107
  };
62
108
  }
63
109
 
@@ -151,12 +197,24 @@ export declare interface BarSeriesOptions {
151
197
  /** @deprecated Use {@link entryAnimation} instead. */
152
198
  enterAnimation?: BarEntryAnimation;
153
199
  /**
154
- * Entrance animation duration in milliseconds. `false` or `0` disables the
155
- * per-bar entrance (equivalent to `entryAnimation: 'none'`). Omit to inherit
156
- * from {@link AnimationsConfig.points}.`entryMs` (default 400).
200
+ * Per-bar entrance duration in milliseconds. Default: `250`.
201
+ *
202
+ * ```
203
+ * // Override for one series:
204
+ * <BarSeries options={{ entryMs: 600 }} data={data} />
205
+ *
206
+ * // Or set the default for every series at once:
207
+ * <ChartContainer animations={{ points: { enterMs: 600 } }}>
208
+ * <BarSeries data={data} />
209
+ * </ChartContainer>
210
+ * ```
157
211
  *
158
- * When `animations.points.entryMs` is `false` at the chart level, the
159
- * entrance is forced off regardless of this field.
212
+ * Note: chart-level uses `enterMs`, per-series uses `entryMs` same
213
+ * animation, two names for historical reasons.
214
+ *
215
+ * `false` or `0` disables the entrance (equivalent to
216
+ * `entryAnimation: 'none'`). A chart-level `animations.points: false` is a
217
+ * hard disable that wins over this field.
160
218
  *
161
219
  * @see BarSeriesOptions.entryAnimation
162
220
  */
@@ -164,13 +222,22 @@ export declare interface BarSeriesOptions {
164
222
  /** @deprecated Use {@link entryMs} instead. */
165
223
  enterMs?: number | false;
166
224
  /**
167
- * Exponential-smoothing time constant (ms) for live-tracking the last
168
- * bar's value under `updateLastPoint`. `0` or `false` snaps directly to the
169
- * target (no smoothing). Omit to inherit from
170
- * {@link AnimationsConfig.points}.`smoothMs` (default 70 ms).
225
+ * How long the displayed bar value takes to catch up to the actual one
226
+ * on every `updateLastPoint`. Default: `250` ms.
227
+ *
228
+ * ```
229
+ * // Per-series override:
230
+ * <BarSeries options={{ smoothMs: 100 }} data={data} />
231
+ *
232
+ * // Chart-level default:
233
+ * <ChartContainer animations={{ points: { smoothMs: 100 } }}>
234
+ * <BarSeries data={data} />
235
+ * </ChartContainer>
236
+ * ```
171
237
  *
172
- * When `animations.points.smoothMs` is `false` at the chart level, smoothing
173
- * is forced off regardless of this field.
238
+ * `0` or `false` snaps the displayed value to the target on every tick
239
+ * (no smoothing). A chart-level `animations.points: false` is a hard
240
+ * disable that wins over this field.
174
241
  */
175
242
  smoothMs?: number | false;
176
243
  }
@@ -277,12 +344,24 @@ export declare interface CandlestickSeriesOptions {
277
344
  /** @deprecated Use {@link entryAnimation} instead. */
278
345
  enterAnimation?: CandlestickEntryAnimation;
279
346
  /**
280
- * Entrance animation duration in milliseconds. `false` or `0` disables the
281
- * per-candle entrance (equivalent to `entryAnimation: 'none'`). Omit to
282
- * inherit from {@link AnimationsConfig.points}.`entryMs` (default 400).
347
+ * Per-candle entrance duration in milliseconds. Default: `250`.
348
+ *
349
+ * ```
350
+ * // Override for one series:
351
+ * <CandlestickSeries options={{ entryMs: 600 }} data={data} />
352
+ *
353
+ * // Or set the default for every series at once:
354
+ * <ChartContainer animations={{ points: { enterMs: 600 } }}>
355
+ * <CandlestickSeries data={data} />
356
+ * </ChartContainer>
357
+ * ```
358
+ *
359
+ * Note: chart-level uses `enterMs`, per-series uses `entryMs` — same
360
+ * animation, two names for historical reasons.
283
361
  *
284
- * When `animations.points.entryMs` is `false` at the chart level, the
285
- * entrance is forced off regardless of this field.
362
+ * `false` or `0` disables the entrance (equivalent to
363
+ * `entryAnimation: 'none'`). A chart-level `animations.points: false` is a
364
+ * hard disable that wins over this field.
286
365
  *
287
366
  * @see CandlestickSeriesOptions.entryAnimation
288
367
  */
@@ -290,13 +369,22 @@ export declare interface CandlestickSeriesOptions {
290
369
  /** @deprecated Use {@link entryMs} instead. */
291
370
  enterMs?: number | false;
292
371
  /**
293
- * Exponential-smoothing time constant (ms) for live-tracking the last
294
- * candle's O/H/L/C under `updateLastPoint`. `0` or `false` snaps directly
295
- * to the target (no smoothing). Omit to inherit from
296
- * {@link AnimationsConfig.points}.`smoothMs` (default 70 ms).
372
+ * How long the displayed OHLC takes to catch up to the actual last value
373
+ * on every `updateLastPoint`. Default: `250` ms.
297
374
  *
298
- * When `animations.points.smoothMs` is `false` at the chart level, smoothing
299
- * is forced off regardless of this field.
375
+ * ```
376
+ * // Per-series override:
377
+ * <CandlestickSeries options={{ smoothMs: 100 }} data={data} />
378
+ *
379
+ * // Chart-level default:
380
+ * <ChartContainer animations={{ points: { smoothMs: 100 } }}>
381
+ * <CandlestickSeries data={data} />
382
+ * </ChartContainer>
383
+ * ```
384
+ *
385
+ * `0` or `false` snaps the displayed value to the target on every tick
386
+ * (no smoothing). A chart-level `animations.points: false` is a hard
387
+ * disable that wins over this field.
300
388
  */
301
389
  smoothMs?: number | false;
302
390
  }
@@ -324,7 +412,7 @@ export declare const catppuccin: ThemePreset;
324
412
  * - Legend — flex sibling at the bottom (or right, when `position="right"`), so its height is
325
413
  * reserved by browser layout.
326
414
  */
327
- export declare function ChartContainer({ children, theme, axis, padding, gradient, interactive, grid, headerLayout, perf, style, className, }: ChartContainerProps): JSX_2.Element;
415
+ export declare function ChartContainer({ children, theme, axis, padding, gradient, interactive, grid, headerLayout, perf, animations, style, className, }: ChartContainerProps): JSX_2.Element;
328
416
 
329
417
  /** Props for the {@link ChartContainer} component. */
330
418
  declare interface ChartContainerProps {
@@ -381,6 +469,36 @@ declare interface ChartContainerProps {
381
469
  * the title. The chart background still spans the full container.
382
470
  */
383
471
  headerLayout?: 'overlay' | 'inline';
472
+ /**
473
+ * Chart-level animation configuration. See {@link AnimationsConfig} for the
474
+ * full shape.
475
+ *
476
+ * Two layers — remember which is which:
477
+ *
478
+ * - **Chart-level (this prop)** — `animations.points.{enterMs, smoothMs,
479
+ * pulseMs}` and `animations.viewport.{reboundMs, yAxisMs,
480
+ * inputResponseMs}`. Acts as the default for every series.
481
+ * - **Per-series** — `<LineSeries options={{ entryMs, smoothMs, pulseMs }}>`
482
+ * (and the analogous CandlestickSeries / BarSeries options). Overrides
483
+ * the chart-level default for that one series. Note the spelling:
484
+ * `entryMs` per-series, `enterMs` chart-level — historical artefact,
485
+ * both refer to the same animation.
486
+ *
487
+ * Resolution: per-series option wins over chart-level numeric value.
488
+ * Chart-level wins only when its category is explicitly `false` — that's
489
+ * a hard disable that overrides per-series too.
490
+ *
491
+ * Shorthands:
492
+ * - `true` / omitted — built-in defaults (every settling animation 250 ms,
493
+ * pulse cycle 600 ms, input ease 0 / off).
494
+ * - `false` — disables every animation category.
495
+ * - `{ points: false }` / `{ viewport: false }` — disables a category.
496
+ *
497
+ * Runtime updates: changing this prop after mount calls
498
+ * `chart.setAnimations(...)` so the new durations take effect on the next
499
+ * animation / render.
500
+ */
501
+ animations?: boolean | AnimationsConfig;
384
502
  /**
385
503
  * Enable runtime performance instrumentation. Off by default.
386
504
  *
@@ -606,6 +724,25 @@ export declare class ChartInstance extends EventEmitter<ChartEvents> {
606
724
  * a wrapper re-applies padding reactively (e.g. in response to a Title /
607
725
  * InfoBar ResizeObserver).
608
726
  */
727
+ /**
728
+ * Replace the chart-level animation configuration at runtime. Updates the
729
+ * resolved durations and propagates them to every dependent subsystem:
730
+ *
731
+ * - viewport: reboundMs (next rebound), inputResponseMs (next pan/zoom).
732
+ * - per-frame: yAxisMs (next render).
733
+ * - existing series: only the **hard-disable** signal (0 / false) is pushed
734
+ * into renderers — that's the documented contract on
735
+ * {@link AnimationsConfig.points}, "chart-level `false` wins over per-
736
+ * series". Numeric chart-level changes update the default for *new*
737
+ * series but leave existing per-series overrides intact, which avoids
738
+ * silently clobbering custom values on every prop update from a React
739
+ * wrapper.
740
+ *
741
+ * In-flight animations are NOT cancelled — the new durations apply to the
742
+ * next animation that fires. To force-snap the current animation, call
743
+ * the relevant API explicitly (e.g. `setRange`) afterwards.
744
+ */
745
+ setAnimations(animations: ChartOptions['animations']): void;
609
746
  setPadding(padding: ChartOptions['padding']): void;
610
747
  /** Show or hide the background grid. Takes effect on the next render frame. */
611
748
  setGrid(grid: {
@@ -634,6 +771,17 @@ export declare class ChartInstance extends EventEmitter<ChartEvents> {
634
771
  private getDataBounds;
635
772
  private onDataChanged;
636
773
  private updateDataInterval;
774
+ /**
775
+ * Sample data inside `targetVisible` and return the unbounded [min, max] of
776
+ * the visible series, or `null` when nothing is in view. Bounds are NOT
777
+ * applied here — the caller composes them via {@link resolveBound}.
778
+ *
779
+ * `targetVisible` is the X *destination* (logicalRange), not the animating
780
+ * current. Sampling against a moving X would make Y chase a definition of
781
+ * "in view" that shifts every frame; passing the destination explicitly
782
+ * keeps Y on a stable target so X and Y converge together.
783
+ */
784
+ private computeTargetYRange;
637
785
  private updateYRange;
638
786
  /** Resolve an {@link AxisBound} to a concrete numeric value. */
639
787
  private resolveBound;
@@ -1175,11 +1323,23 @@ export declare interface LineSeriesOptions {
1175
1323
  */
1176
1324
  pulse: boolean;
1177
1325
  /**
1178
- * Pulse cycle period in milliseconds. `false`/`0` disables the halo (both
1179
- * the drawing and the associated animation loop). Omit to inherit from
1180
- * {@link AnimationsConfig.points}.`pulseMs` (default 600 ms). When
1181
- * `animations.points.pulseMs` is `false` at the chart level the pulse is
1182
- * forced off regardless of this field.
1326
+ * Period of one halo pulse cycle in milliseconds. Continuous loop, not a
1327
+ * one-shot short values pulse fast, long values pulse slowly. Default:
1328
+ * `600` ( 1.7 Hz, a calm "breathing" rhythm).
1329
+ *
1330
+ * ```
1331
+ * // Per-series override:
1332
+ * <LineSeries options={{ pulseMs: 1200 }} data={data} />
1333
+ *
1334
+ * // Chart-level default:
1335
+ * <ChartContainer animations={{ points: { pulseMs: 1200 } }}>
1336
+ * <LineSeries data={data} />
1337
+ * </ChartContainer>
1338
+ * ```
1339
+ *
1340
+ * `false` or `0` turns the halo off entirely (drawing and animation loop).
1341
+ * A chart-level `animations.points: false` is a hard disable that wins
1342
+ * over this field.
1183
1343
  */
1184
1344
  pulseMs?: number | false;
1185
1345
  /** Stacking mode. Default: 'off'. */
@@ -1195,12 +1355,24 @@ export declare interface LineSeriesOptions {
1195
1355
  /** @deprecated Use {@link entryAnimation} instead. */
1196
1356
  enterAnimation?: LineEntryAnimation;
1197
1357
  /**
1198
- * Entrance animation duration in milliseconds. `false` or `0` disables the
1199
- * per-point entrance (equivalent to `entryAnimation: 'none'`). Omit to
1200
- * inherit from {@link AnimationsConfig.points}.`entryMs` (default 400).
1358
+ * Per-point entrance duration in milliseconds. Default: `250`.
1201
1359
  *
1202
- * When `animations.points.entryMs` is `false` at the chart level, the
1203
- * entrance is forced off regardless of this field.
1360
+ * ```
1361
+ * // Override for one series:
1362
+ * <LineSeries options={{ entryMs: 600 }} data={data} />
1363
+ *
1364
+ * // Or set the default for every series at once:
1365
+ * <ChartContainer animations={{ points: { enterMs: 600 } }}>
1366
+ * <LineSeries data={data} />
1367
+ * </ChartContainer>
1368
+ * ```
1369
+ *
1370
+ * Note: chart-level uses `enterMs`, per-series uses `entryMs` — same
1371
+ * animation, two names for historical reasons.
1372
+ *
1373
+ * `false` or `0` disables the entrance (equivalent to
1374
+ * `entryAnimation: 'none'`). A chart-level `animations.points: false` is a
1375
+ * hard disable that wins over this field.
1204
1376
  *
1205
1377
  * @see LineSeriesOptions.entryAnimation
1206
1378
  */
@@ -1208,13 +1380,22 @@ export declare interface LineSeriesOptions {
1208
1380
  /** @deprecated Use {@link entryMs} instead. */
1209
1381
  enterMs?: number | false;
1210
1382
  /**
1211
- * Exponential-smoothing time constant (ms) for live-tracking the last
1212
- * point's value under `updateLastPoint`. `0` or `false` snaps directly to
1213
- * the target (no smoothing). Omit to inherit from
1214
- * {@link AnimationsConfig.points}.`smoothMs` (default 70 ms).
1383
+ * How long the displayed last value takes to catch up to the actual one
1384
+ * on every `updateLastPoint`. Default: `250` ms.
1385
+ *
1386
+ * ```
1387
+ * // Per-series override:
1388
+ * <LineSeries options={{ smoothMs: 100 }} data={data} />
1389
+ *
1390
+ * // Chart-level default:
1391
+ * <ChartContainer animations={{ points: { smoothMs: 100 } }}>
1392
+ * <LineSeries data={data} />
1393
+ * </ChartContainer>
1394
+ * ```
1215
1395
  *
1216
- * When `animations.points.smoothMs` is `false` at the chart level, smoothing
1217
- * is forced off regardless of this field.
1396
+ * `0` or `false` snaps the displayed value to the target on every tick
1397
+ * (no smoothing). A chart-level `animations.points: false` is a hard
1398
+ * disable that wins over this field.
1218
1399
  */
1219
1400
  smoothMs?: number | false;
1220
1401
  }