@wick-charts/vue 0.6.3 → 0.7.0

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.
Files changed (67) hide show
  1. package/README.md +6 -6
  2. package/dist/BandSeries.vue.js +52 -0
  3. package/dist/BandSeries.vue2.js +4 -0
  4. package/dist/BarSeries.vue.js +15 -13
  5. package/dist/CandlestickSeries.vue.js +31 -29
  6. package/dist/ChartContainer.vue.js +75 -68
  7. package/dist/LineSeries.vue.js +19 -17
  8. package/dist/composables.js +46 -36
  9. package/dist/core/dist/animation/config.js +92 -75
  10. package/dist/core/dist/animation/viewport-engine.js +155 -96
  11. package/dist/core/dist/axis/dom-labels.js +56 -51
  12. package/dist/core/dist/chart/badge-animator.js +30 -22
  13. package/dist/core/dist/chart/edge-indicators.js +22 -21
  14. package/dist/core/dist/chart/last-value.js +33 -26
  15. package/dist/core/dist/chart/scale-guards.js +23 -5
  16. package/dist/core/dist/chart/x-guards.js +37 -0
  17. package/dist/core/dist/chart.js +1286 -842
  18. package/dist/core/dist/data/decimation.js +58 -39
  19. package/dist/core/dist/data/sync.js +37 -31
  20. package/dist/core/dist/navigator/controller.js +41 -41
  21. package/dist/core/dist/perf/perf-hud.js +3 -3
  22. package/dist/core/dist/scales/tick-tracker.js +2 -2
  23. package/dist/core/dist/scales/x-scale.js +167 -53
  24. package/dist/core/dist/scales/y-scale.js +36 -34
  25. package/dist/core/dist/series/band.js +723 -0
  26. package/dist/core/dist/series/bar.js +297 -291
  27. package/dist/core/dist/series/base-multi-layer.js +283 -237
  28. package/dist/core/dist/series/candlestick.js +32 -31
  29. package/dist/core/dist/series/heatmap.js +5 -5
  30. package/dist/core/dist/series/line-intro.js +47 -37
  31. package/dist/core/dist/series/line.js +489 -448
  32. package/dist/core/dist/series/painters/builtins.js +4 -4
  33. package/dist/core/dist/series/painters/canvas-path.js +64 -52
  34. package/dist/core/dist/series/register-builtins.js +9 -8
  35. package/dist/core/dist/snapshots.js +59 -46
  36. package/dist/core/dist/utils/point.js +10 -0
  37. package/dist/index.d.ts +552 -129
  38. package/dist/index.js +195 -191
  39. package/dist/ui/Crosshair.vue.js +51 -27
  40. package/dist/ui/InfoBar.vue.js +98 -79
  41. package/dist/ui/Marker.vue.js +14 -11
  42. package/dist/ui/Navigator.vue.js +23 -23
  43. package/dist/ui/ReferenceLine.vue.js +19 -16
  44. package/dist/ui/Tooltip.vue.js +116 -84
  45. package/dist/ui/XAxis.vue.js +48 -0
  46. package/dist/ui/XAxis.vue2.js +4 -0
  47. package/dist/ui/YAxis.vue.js +44 -28
  48. package/dist/ui/YLabel.vue.js +82 -85
  49. package/package.json +2 -2
  50. package/src/BandSeries.vue +92 -0
  51. package/src/BarSeries.vue +13 -6
  52. package/src/CandlestickSeries.vue +9 -5
  53. package/src/ChartContainer.vue +20 -0
  54. package/src/LineSeries.vue +13 -6
  55. package/src/composables.ts +23 -4
  56. package/src/index.ts +16 -1
  57. package/src/ui/Crosshair.vue +41 -1
  58. package/src/ui/InfoBar.vue +22 -2
  59. package/src/ui/Marker.vue +5 -1
  60. package/src/ui/Navigator.vue +2 -1
  61. package/src/ui/ReferenceLine.vue +5 -1
  62. package/src/ui/Tooltip.vue +43 -6
  63. package/src/ui/{TimeAxis.vue → XAxis.vue} +18 -5
  64. package/src/ui/YAxis.vue +66 -12
  65. package/src/ui/YLabel.vue +37 -18
  66. package/dist/ui/TimeAxis.vue.js +0 -44
  67. package/dist/ui/TimeAxis.vue2.js +0 -4
@@ -1,31 +1,63 @@
1
- class g {
2
- #t;
1
+ class c {
3
2
  #i;
4
- #r;
5
- #e;
6
- #g;
3
+ /** Y slots of the named scales, keyed by scale id. */
4
+ #s = /* @__PURE__ */ new Map();
5
+ #u;
6
+ #t;
7
+ #a;
8
+ #h;
9
+ #m;
7
10
  /** Per-frame `animating` snapshot — updated by `tick` so `get animating()`
8
11
  * is O(1). Spans both axes; lives at the engine root rather than in
9
12
  * XState/YState because it's a cross-axis flag. */
10
- #s = !1;
13
+ #n = !1;
11
14
  constructor(t) {
12
- this.#t = {
13
- transition: t.y.curve({ initial: t.initial.yRange }),
14
- settleMs: t.y.settleMs,
15
- stickyMs: t.y.stickyMs,
16
- stickyFloorMs: t.y.stickyFloorMs,
17
- gestureMs: t.y.gestureMs,
18
- toggleMs: t.y.toggleMs,
19
- toggleUntil: 0
20
- }, this.#i = {
15
+ this.#u = t.y, this.#i = this.#f({ initial: t.initial.yRange, primed: !0 }), this.#t = {
21
16
  transition: t.x.curve({ initial: t.initial.xRange }),
22
17
  settleMs: t.x.settleMs,
23
18
  gestureMs: t.x.gestureMs,
24
19
  lastTarget: null,
25
20
  gestureUntil: 0
26
- }, this.#r = t.computeXTarget, this.#e = t.computeYTarget, this.#g = t.onWake;
21
+ }, this.#a = t.computeXTarget, this.#h = t.computeYTarget, this.#m = t.onWake;
27
22
  }
28
23
  // --- Helpers -------------------------------------------------------------
24
+ #f(t) {
25
+ const s = this.#u;
26
+ return {
27
+ transition: s.curve({ initial: t.initial }),
28
+ settleMs: s.settleMs,
29
+ stickyMs: s.stickyMs,
30
+ stickyFloorMs: s.stickyFloorMs,
31
+ gestureMs: s.gestureMs,
32
+ toggleMs: s.toggleMs,
33
+ toggleUntil: 0,
34
+ primed: t.primed
35
+ };
36
+ }
37
+ /** Every Y slot with the target the chart computes for it against `xTarget`. */
38
+ #r(t) {
39
+ const s = [{ y: this.#i, target: this.#h({ xTarget: t }) }];
40
+ for (const [i, e] of this.#s)
41
+ s.push({ y: e, target: this.#h({ xTarget: t, scale: i }) });
42
+ return s;
43
+ }
44
+ /** Ease a Y slot to `target` — or snap, when it's the slot's first target. */
45
+ #g(t, s, i) {
46
+ if (!t.primed) {
47
+ this.#o(t, s, i.now);
48
+ return;
49
+ }
50
+ t.transition.retarget(s, i);
51
+ }
52
+ #o(t, s, i) {
53
+ t.transition.snap(s, { now: i }), t.primed = !0;
54
+ }
55
+ #M() {
56
+ if (this.#i.transition.animating) return !0;
57
+ for (const t of this.#s.values())
58
+ if (t.transition.animating) return !0;
59
+ return !1;
60
+ }
29
61
  /**
30
62
  * Retarget X and record `#x.lastTarget` — autoscroll consults that field for
31
63
  * the logical destination, not the in-flight visual.
@@ -34,15 +66,15 @@ class g {
34
66
  * (fast — responsive feel) while stream ticks pass `#x.settleMs` (the
35
67
  * cadence-tuned baseline).
36
68
  */
37
- #a(t, s, i) {
38
- this.#i.transition.retarget(t, { now: s, expandMs: i }), this.#i.lastTarget = { from: t.from, to: t.to };
69
+ #l(t, s, i) {
70
+ this.#t.transition.retarget(t, { now: s, expandMs: i }), this.#t.lastTarget = { from: t.from, to: t.to };
39
71
  }
40
- #o(t, s) {
41
- this.#i.transition.snap({ from: t.from, to: t.to }, { now: s }), this.#i.lastTarget = { from: t.from, to: t.to };
72
+ #c(t, s) {
73
+ this.#t.transition.snap({ from: t.from, to: t.to }, { now: s }), this.#t.lastTarget = { from: t.from, to: t.to };
42
74
  }
43
75
  /** Fire `onWake` once when an idle engine receives a new retarget. */
44
- #n(t) {
45
- t && this.#g?.();
76
+ #e(t) {
77
+ t && this.#m?.();
46
78
  }
47
79
  /**
48
80
  * Magnitude-scaled inward (sticky) settle time. The configured `stickyMs`
@@ -60,115 +92,142 @@ class g {
60
92
  * contracts. `stickyFloorMs === stickyMs` collapses this back to a fixed
61
93
  * duration.
62
94
  */
63
- #h(t, s) {
64
- const i = this.#t.stickyMs;
65
- if (i <= 0) return i;
66
- const n = Math.max(t.max - t.min, Number.EPSILON), e = Math.max(0, s.min - t.min), r = Math.max(0, t.max - s.max), a = Math.min(1, Math.max(e, r) / n), h = Math.min(this.#t.stickyFloorMs, i);
67
- return Math.max(h, i * a);
95
+ #p(t, s) {
96
+ const i = t.transition.current, e = t.stickyMs;
97
+ if (e <= 0) return e;
98
+ const n = Math.max(i.max - i.min, Number.EPSILON), r = Math.max(0, s.min - i.min), o = Math.max(0, i.max - s.max), a = Math.min(1, Math.max(r, o) / n), h = Math.min(t.stickyFloorMs, e);
99
+ return Math.max(h, e * a);
68
100
  }
69
101
  // --- Inputs --------------------------------------------------------------
70
102
  onPointAppended(t) {
71
103
  const s = t ?? performance.now();
72
- if (s < this.#i.gestureUntil) return;
73
- const i = this.#r(), n = i ?? this.#i.transition.target, e = this.#e({ xTarget: n });
74
- if (i === null && e === null) return;
75
- const r = !this.#s, a = s < this.#t.toggleUntil;
76
- i !== null && this.#a(i, s, this.#i.settleMs), e !== null && !a && this.#t.transition.retarget(e, {
77
- now: s,
78
- expandMs: this.#t.settleMs,
79
- contractMs: this.#h(this.#t.transition.current, e)
80
- }), this.#n(r);
104
+ if (s < this.#t.gestureUntil) return;
105
+ const i = this.#a(), e = i ?? this.#t.transition.target, n = this.#r(e), r = n.some((a) => a.target !== null);
106
+ if (i === null && !r) return;
107
+ const o = !this.#n;
108
+ i !== null && this.#l(i, s, this.#t.settleMs);
109
+ for (const { y: a, target: h } of n) {
110
+ const l = s < a.toggleUntil;
111
+ h === null || l || this.#g(a, h, {
112
+ now: s,
113
+ expandMs: a.settleMs,
114
+ contractMs: this.#p(a, h)
115
+ });
116
+ }
117
+ this.#e(o);
81
118
  }
82
119
  onSeriesVisibilityChanged(t) {
83
- const s = this.#e({ xTarget: this.#i.transition.target });
84
- if (s === null) return;
85
- const i = t ?? performance.now(), n = !this.#s;
86
- this.#t.toggleMs > 0 ? (this.#t.transition.snap(this.#t.transition.current, { now: i }), this.#t.transition.retarget(s, {
87
- now: i,
88
- expandMs: this.#t.toggleMs,
89
- contractMs: this.#t.toggleMs
90
- }), this.#t.toggleUntil = i + this.#t.toggleMs) : (this.#t.transition.snap(s, { now: i }), this.#t.toggleUntil = 0), this.#n(n);
120
+ const s = this.#r(this.#t.transition.target);
121
+ if (s.every((n) => n.target === null)) return;
122
+ const i = t ?? performance.now(), e = !this.#n;
123
+ for (const { y: n, target: r } of s)
124
+ r !== null && (n.toggleMs > 0 && n.primed ? (n.transition.snap(n.transition.current, { now: i }), n.transition.retarget(r, {
125
+ now: i,
126
+ expandMs: n.toggleMs,
127
+ contractMs: n.toggleMs
128
+ }), n.toggleUntil = i + n.toggleMs) : (this.#o(n, r, i), n.toggleUntil = 0));
129
+ this.#e(e);
91
130
  }
92
131
  onPanZoom(t, s) {
93
- const i = s ?? performance.now(), n = !this.#s;
94
- if (this.#a(t.xTarget, i, this.#i.gestureMs), this.#i.gestureUntil = i + 100, t.yAuto) {
95
- const e = this.#e({ xTarget: t.xTarget });
96
- e !== null && this.#t.transition.retarget(e, {
97
- now: i,
98
- expandMs: this.#t.gestureMs,
99
- contractMs: this.#t.gestureMs
100
- });
101
- }
102
- this.#n(n);
132
+ const i = s ?? performance.now(), e = !this.#n;
133
+ if (this.#l(t.xTarget, i, this.#t.gestureMs), this.#t.gestureUntil = i + 100, t.yAuto)
134
+ for (const { y: n, target: r } of this.#r(t.xTarget))
135
+ r !== null && this.#g(n, r, {
136
+ now: i,
137
+ expandMs: n.gestureMs,
138
+ contractMs: n.gestureMs
139
+ });
140
+ this.#e(e);
103
141
  }
104
142
  onAxisReconfig(t) {
105
- const s = this.#e({ xTarget: this.#i.transition.target });
106
- if (s === null) return;
107
- const i = t ?? performance.now(), n = !this.#s;
108
- this.#t.transition.snap(s, { now: i }), this.#n(n);
143
+ const s = this.#r(this.#t.transition.target);
144
+ if (s.every((n) => n.target === null)) return;
145
+ const i = t ?? performance.now(), e = !this.#n;
146
+ for (const { y: n, target: r } of s)
147
+ r !== null && this.#o(n, r, i);
148
+ this.#e(e);
109
149
  }
110
150
  onProgrammaticZoom(t, s) {
111
- this.#i.gestureUntil = 0;
112
- const i = this.#e({ xTarget: t.xTarget }), n = s ?? performance.now(), e = !this.#s;
113
- if (t.xEase === !0) {
114
- this.#a(t.xTarget, n, this.#i.gestureMs), i !== null && this.#t.transition.retarget(i, {
115
- now: n,
116
- expandMs: this.#t.settleMs,
117
- contractMs: this.#h(this.#t.transition.current, i)
118
- }), this.#n(e);
119
- return;
120
- }
121
- this.#o(t.xTarget, n), i !== null && this.#t.transition.retarget(i, {
122
- now: n,
123
- expandMs: this.#t.settleMs,
124
- contractMs: this.#h(this.#t.transition.current, i)
125
- }), this.#n(e);
151
+ this.#t.gestureUntil = 0;
152
+ const i = this.#r(t.xTarget), e = s ?? performance.now(), n = !this.#n;
153
+ t.xEase === !0 ? this.#l(t.xTarget, e, this.#t.gestureMs) : this.#c(t.xTarget, e);
154
+ for (const { y: r, target: o } of i)
155
+ o !== null && this.#g(r, o, {
156
+ now: e,
157
+ expandMs: r.settleMs,
158
+ contractMs: this.#p(r, o)
159
+ });
160
+ this.#e(n);
126
161
  }
127
162
  onDataReplaced(t) {
128
- const s = this.#r(), i = this.#e({ xTarget: s ?? this.#i.transition.target });
129
- if (s === null && i === null) return;
130
- const n = t ?? performance.now(), e = !this.#s;
131
- s !== null && this.#o(s, n), i !== null && this.#t.transition.snap(i, { now: n }), this.#n(e);
163
+ const s = this.#a(), i = this.#r(s ?? this.#t.transition.target), e = i.some((o) => o.target !== null);
164
+ if (s === null && !e) return;
165
+ const n = t ?? performance.now(), r = !this.#n;
166
+ s !== null && this.#c(s, n);
167
+ for (const { y: o, target: a } of i)
168
+ a !== null && this.#o(o, a, n);
169
+ this.#e(r);
132
170
  }
133
171
  snap(t, s) {
134
- this.#i.gestureUntil = 0;
135
- const i = s ?? performance.now(), n = !this.#s;
136
- t.x !== void 0 && this.#o(t.x, i), t.y !== void 0 && this.#t.transition.snap(t.y, { now: i }), this.#n(n);
172
+ this.#t.gestureUntil = 0;
173
+ const i = s ?? performance.now(), e = !this.#n;
174
+ t.x !== void 0 && this.#c(t.x, i), t.y !== void 0 && this.#o(this.#i, t.y, i);
175
+ for (const [n, r] of Object.entries(t.scales ?? {})) {
176
+ const o = this.#s.get(n);
177
+ o !== void 0 && this.#o(o, r, i);
178
+ }
179
+ this.#e(e);
180
+ }
181
+ /**
182
+ * Keep one Y slot per named scale: add slots for new ids (empty until their
183
+ * first target, which snaps) and drop slots for ids no longer listed.
184
+ */
185
+ setYScales(t) {
186
+ for (const s of this.#s.keys())
187
+ t.includes(s) || this.#s.delete(s);
188
+ for (const s of t)
189
+ this.#s.has(s) || this.#s.set(s, this.#f({ initial: { min: 0, max: 0 }, primed: !1 }));
137
190
  }
138
191
  // --- Outputs -------------------------------------------------------------
139
192
  tick(t) {
140
- this.#i.transition.tick(t), this.#t.transition.tick(t);
141
- const s = this.#i.transition.animating || this.#t.transition.animating;
142
- return this.#s = s, {
143
- xRange: this.#i.transition.current,
144
- yRange: this.#t.transition.current,
193
+ this.#t.transition.tick(t), this.#i.transition.tick(t);
194
+ for (const i of this.#s.values())
195
+ i.transition.tick(t);
196
+ const s = this.#t.transition.animating || this.#M();
197
+ return this.#n = s, {
198
+ xRange: this.#t.transition.current,
199
+ yRange: this.#i.transition.current,
145
200
  animating: s
146
201
  };
147
202
  }
148
203
  getAnimationState() {
149
204
  return {
150
- xRange: this.#i.transition.current,
151
- yRange: this.#t.transition.current,
152
- animating: this.#i.transition.animating || this.#t.transition.animating
205
+ xRange: this.#t.transition.current,
206
+ yRange: this.#i.transition.current,
207
+ animating: this.animating
153
208
  };
154
209
  }
210
+ /** Current (eased) Y of a named scale, `null` for an unknown id. */
211
+ getScaleYRange(t) {
212
+ return this.#s.get(t)?.transition.current ?? null;
213
+ }
155
214
  getTarget() {
156
- return { x: this.#i.transition.target, y: this.#t.transition.target };
215
+ return { x: this.#t.transition.target, y: this.#i.transition.target };
157
216
  }
158
217
  get animating() {
159
- return this.#i.transition.animating || this.#t.transition.animating;
218
+ return this.#t.transition.animating || this.#M();
160
219
  }
161
220
  get lastXTarget() {
162
- return this.#i.lastTarget;
221
+ return this.#t.lastTarget;
163
222
  }
164
223
  setXSettleMs(t) {
165
- this.#i.settleMs = t;
224
+ this.#t.settleMs = t;
166
225
  }
167
226
  }
168
- function l(o) {
169
- return new g(o);
227
+ function u(g) {
228
+ return new c(g);
170
229
  }
171
230
  export {
172
- g as ViewportEngine,
173
- l as createViewportEngine
231
+ c as ViewportEngine,
232
+ u as createViewportEngine
174
233
  };
@@ -1,72 +1,77 @@
1
- import { resolveAxisTextColor as I, resolveAxisFontSize as C } from "../theme/resolve.js";
2
- import { clamp as P } from "../utils/math.js";
3
- const V = 0.01;
4
- function E(T) {
5
- const { chart: e, container: w, axis: a } = T, r = /* @__PURE__ */ new Map();
6
- let p = null, m = null;
7
- const x = a === "x" ? e.timeScale.tickTracker : e.yScale.tickTracker;
8
- function A() {
9
- return a === "x" ? e.timeScale.niceTickValues(e.getDataInterval()) : { ticks: e.yScale.niceTickValues(), tickInterval: 0 };
1
+ import { resolveAxisTextColor as X, resolveAxisFontSize as w } from "../theme/resolve.js";
2
+ import { clamp as z } from "../utils/math.js";
3
+ const E = 0.01;
4
+ function D(A) {
5
+ const { chart: n, container: F, axis: a, scale: x } = A, s = /* @__PURE__ */ new Map();
6
+ let g = null, h = null;
7
+ function c() {
8
+ return n.getYScale(x);
9
+ }
10
+ function m() {
11
+ return n.getYScaleColumn(x)?.position ?? n.yAxisPosition;
12
+ }
13
+ function Y() {
14
+ return a === "x" ? n.timeScale.niceTickValues(n.getDataInterval()) : { ticks: c().niceTickValues(), tickInterval: 0 };
10
15
  }
11
16
  function S(t, o) {
12
- return a === "x" ? e.timeScale.formatX(t, o) : e.yScale.formatY(t);
17
+ return a === "x" ? n.timeScale.formatX(t, o) : c().formatY(t);
13
18
  }
14
19
  function $(t, o) {
15
20
  if (a === "x") {
16
- t.style.left = `${e.timeScale.timeToSnappedX(o)}px`;
21
+ t.style.left = `${n.timeScale.timeToSnappedX(o)}px`, n.timeScale.getType() === "category" && (t.style.maxWidth = `${n.timeScale.barWidthMedia(1)}px`);
17
22
  return;
18
23
  }
19
- t.style.top = `${e.yScale.valueToSnappedY(o)}px`;
20
- }
21
- function h(t, o) {
22
- t.style.color = I(o, a), t.style.fontSize = `${C(o, a)}px`, t.style.fontFamily = o.typography.fontFamily;
24
+ t.style.top = `${c().valueToSnappedY(o)}px`;
23
25
  }
24
26
  function v(t, o) {
25
- const i = o === "left" ? "left" : "right", n = o === "left" ? "right" : "left";
26
- t.style[i] = "8px", t.style[n] = "";
27
+ t.style.color = X(o, a), t.style.fontSize = `${w(o, a)}px`, t.style.fontFamily = o.typography.fontFamily;
27
28
  }
28
- function F(t, o) {
29
- const i = e.headerHeight;
30
- if (a !== "y" || i <= 0 || e.yAxisPosition !== "left") return 1;
31
- const n = C(o, a), y = e.yScale.valueToSnappedY(t) - n / 2;
32
- return P((y - i + n) / n, 0, 1);
29
+ function d(t, o) {
30
+ const i = o === "left" ? "left" : "right", e = o === "left" ? "right" : "left";
31
+ t.style[i] = "8px", t.style[e] = "";
33
32
  }
34
- function Y(t, o, i) {
35
- const n = document.createElement("span");
36
- return n.textContent = S(t, o), n.style.position = "absolute", n.style.userSelect = "none", h(n, i), n.style.willChange = "opacity", a === "x" ? (n.style.transform = "translateX(-50%)", n.style.whiteSpace = "nowrap") : (v(n, e.yAxisPosition), n.style.transform = "translateY(-50%)", n.style.fontVariantNumeric = "tabular-nums"), w.appendChild(n), n;
33
+ function b(t, o) {
34
+ const i = n.headerHeight;
35
+ if (a !== "y" || i <= 0 || m() !== "left") return 1;
36
+ const e = w(o, a), p = c().valueToSnappedY(t) - e / 2;
37
+ return z((p - i + e) / e, 0, 1);
37
38
  }
38
- function c() {
39
- const t = e.getTheme(), o = t !== p;
40
- p = t;
41
- const i = e.yAxisPosition, n = a === "y" && i !== m;
42
- m = i;
43
- const { ticks: y, tickInterval: g } = A();
44
- x.setCurrentTicks(y);
45
- const { entries: b } = x.snapshot(), k = /* @__PURE__ */ new Set();
46
- for (const { value: s, opacity: u } of b) {
47
- if (u <= V) continue;
48
- k.add(s);
49
- let l = r.get(s);
50
- if (l === void 0)
51
- l = Y(s, g, t), r.set(s, l);
39
+ function I(t, o, i) {
40
+ const e = document.createElement("span");
41
+ return e.textContent = S(t, o), e.style.position = "absolute", e.style.userSelect = "none", v(e, i), e.style.willChange = "opacity", a === "x" ? (e.style.transform = "translateX(-50%)", e.style.whiteSpace = "nowrap", n.timeScale.getType() === "category" && (e.style.overflow = "hidden", e.style.textOverflow = "ellipsis")) : (d(e, m()), e.style.transform = "translateY(-50%)", e.style.fontVariantNumeric = "tabular-nums"), F.appendChild(e), e;
42
+ }
43
+ function f() {
44
+ const t = n.getTheme(), o = t !== g;
45
+ g = t;
46
+ const i = m(), e = a === "y" && i !== h;
47
+ h = i;
48
+ const p = a === "x" ? n.timeScale.tickTracker : c().tickTracker, { ticks: V, tickInterval: k } = Y();
49
+ p.setCurrentTicks(V);
50
+ const { entries: W } = p.snapshot(), C = /* @__PURE__ */ new Set();
51
+ for (const { value: l, opacity: y } of W) {
52
+ if (y <= E) continue;
53
+ C.add(l);
54
+ let r = s.get(l);
55
+ if (r === void 0)
56
+ r = I(l, k, t), s.set(l, r);
52
57
  else {
53
- const d = S(s, g);
54
- l.textContent !== d && (l.textContent = d), o && h(l, t), n && v(l, i);
58
+ const T = S(l, k);
59
+ r.textContent !== T && (r.textContent = T), o && v(r, t), e && d(r, i);
55
60
  }
56
- $(l, s), l.style.opacity = String(u * F(s, t));
61
+ $(r, l), r.style.opacity = String(y * b(l, t));
57
62
  }
58
- for (const [s, u] of r)
59
- k.has(s) || (u.remove(), r.delete(s));
63
+ for (const [l, y] of s)
64
+ C.has(l) || (y.remove(), s.delete(l));
60
65
  }
61
- function f() {
62
- e.getAnimationState().animating || c();
66
+ function u() {
67
+ n.getAnimationState().animating || f();
63
68
  }
64
- return c(), e.on("tickFrame", c), e.on("viewportChange", f), e.on("overlayChange", f), () => {
65
- e.off("tickFrame", c), e.off("viewportChange", f), e.off("overlayChange", f);
66
- for (const t of r.values()) t.remove();
67
- r.clear();
69
+ return f(), n.on("tickFrame", f), n.on("viewportChange", u), n.on("overlayChange", u), () => {
70
+ n.off("tickFrame", f), n.off("viewportChange", u), n.off("overlayChange", u);
71
+ for (const t of s.values()) t.remove();
72
+ s.clear();
68
73
  };
69
74
  }
70
75
  export {
71
- E as mountAxisLabels
76
+ D as mountAxisLabels
72
77
  };
@@ -1,6 +1,6 @@
1
1
  import { ScalarSpring as g } from "../animation/scalar-spring.js";
2
- const r = 320, V = 0.15;
3
- class x {
2
+ const l = 320, V = 0.15;
3
+ class b {
4
4
  #t;
5
5
  #e;
6
6
  #i = !1;
@@ -8,45 +8,53 @@ class x {
8
8
  this.#t = new g(i), this.#e = i;
9
9
  }
10
10
  frame(i) {
11
- const { target: t, firstVisible: n, introFront: o, now: s, glide: u = !0, countUp: l = !0, reducedMotion: p = !1 } = i;
12
- if (p || !u && !l)
11
+ const { target: t, firstVisible: n, introFront: r, now: s, glide: a = !0, countUp: u = !0, reducedMotion: p = !1 } = i;
12
+ if (p || !a && !u)
13
13
  return this.#t.snap(t, { now: s }), this.#e = t, this.#i = !0, { positionValue: t, textValue: t, opacity: 1, animating: !1 };
14
- if (o < 1) {
15
- const f = n + (t - n) * o, a = l ? f : t;
16
- return this.#t.snap(a, { now: s }), this.#e = a, this.#i = !0, { positionValue: a, textValue: a, opacity: this.#s(o), animating: !0 };
14
+ if (r < 1) {
15
+ const h = n + (t - n) * r, o = u ? h : t;
16
+ return this.#t.snap(o, { now: s }), this.#e = o, this.#i = !0, { positionValue: o, textValue: o, opacity: this.#s(r), animating: !0 };
17
17
  }
18
18
  if (!this.#i)
19
19
  return this.#t.snap(t, { now: s }), this.#e = t, this.#i = !0, { positionValue: t, textValue: t, opacity: 1, animating: !1 };
20
- if (!u)
20
+ if (!a)
21
21
  return this.#t.snap(t, { now: s }), this.#e = t, { positionValue: t, textValue: t, opacity: 1, animating: !1 };
22
- const c = i.settleMs ?? r;
22
+ const c = i.settleMs ?? l;
23
23
  if (c <= 0)
24
24
  return this.#t.snap(t, { now: s }), this.#e = t, { positionValue: t, textValue: t, opacity: 1, animating: !1 };
25
- Math.abs(t - this.#e) > m && (this.#t.retarget(t, { now: s, settleMs: c }), this.#e = t);
26
- const h = this.#t.tick(s);
27
- return { positionValue: this.#t.current, textValue: t, opacity: 1, animating: h };
25
+ Math.abs(t - this.#e) > d && (this.#t.retarget(t, { now: s, settleMs: c }), this.#e = t);
26
+ const f = this.#t.tick(s);
27
+ return { positionValue: this.#t.current, textValue: t, opacity: 1, animating: f };
28
28
  }
29
29
  #s(i) {
30
- return i >= 1 ? 1 : d(i / V);
30
+ return i >= 1 ? 1 : y(i / V);
31
31
  }
32
32
  }
33
- const m = 1e-9;
34
- function d(e) {
33
+ const d = 1e-9;
34
+ function y(e) {
35
35
  return e <= 0 ? 0 : e >= 1 ? 1 : e;
36
36
  }
37
- function M(e) {
38
- return e === !1 ? { glide: !1, countUp: !1, settleMs: 0 } : e === void 0 || e === !0 ? { glide: !0, countUp: !0, settleMs: r } : {
37
+ function w(e) {
38
+ return e === !1 ? { glide: !1, countUp: !1, settleMs: 0 } : e === void 0 || e === !0 ? { glide: !0, countUp: !0, settleMs: l } : {
39
39
  glide: e.glide ?? !0,
40
40
  countUp: e.countUp ?? !0,
41
- settleMs: e.settleMs ?? r
41
+ settleMs: e.settleMs ?? l
42
42
  };
43
43
  }
44
- function y(e, i, t) {
44
+ function M(e, i, t) {
45
45
  const { from: n } = e.getVisibleRange();
46
46
  return e.getStackedValueAtTime(i, n) ?? t;
47
47
  }
48
+ function S(e, i) {
49
+ if (i !== void 0) return i;
50
+ const t = new Set(e.getSeriesIdsByType("band")), n = (a) => !t.has(a), r = e.getSeriesIdsByType("time", { visibleOnly: !0, singleLayerOnly: !0 }).filter(n);
51
+ if (r.length > 0) return r[0];
52
+ const s = e.getSeriesIdsByType("time", { visibleOnly: !0 }).filter(n);
53
+ return s.length > 0 ? s[0] : null;
54
+ }
48
55
  export {
49
- x as BadgeAnimator,
50
- y as firstVisibleValue,
51
- M as resolveAnimate
56
+ b as BadgeAnimator,
57
+ M as firstVisibleValue,
58
+ w as resolveAnimate,
59
+ S as resolveYLabelSeriesId
52
60
  };
@@ -1,41 +1,42 @@
1
1
  import { renderEdgeIndicator as s } from "../components/edge-indicator.js";
2
- function d(e) {
3
- const o = performance.now();
4
- for (const t of ["left", "right"]) {
5
- let r = e.edgeStates[t], n = 1;
2
+ import { pointValue as c } from "../utils/point.js";
3
+ function h(e) {
4
+ const t = performance.now();
5
+ for (const o of ["left", "right"]) {
6
+ let r = e.edgeStates[o], n = 1;
6
7
  if (r === "idle" || r === "has-more") {
7
- const a = e.edgeExitFades[t];
8
+ const a = e.edgeExitFades[o];
8
9
  if (a === null) continue;
9
10
  r = "loading", n = a;
10
11
  }
11
- const l = e.resolveBoundary(t);
12
+ const l = e.resolveBoundary(o);
12
13
  if (l === null) continue;
13
- const { context: c } = e.scope;
14
- n < 1 && (c.save(), c.globalAlpha *= n), s({
14
+ const { context: i } = e.scope;
15
+ n < 1 && (i.save(), i.globalAlpha *= n), s({
15
16
  scope: e.scope,
16
17
  timeScale: e.timeScale,
17
18
  theme: e.theme,
18
19
  chartMediaWidth: e.chartMediaWidth,
19
20
  chartMediaHeight: e.chartMediaHeight,
20
21
  boundaryTime: l,
21
- side: t,
22
+ side: o,
22
23
  state: r,
23
- now: o,
24
- customIndicator: e.edgeIndicatorFns[t],
25
- resolveEdgeAnchor: () => e.resolveEdgeAnchor(t, l),
24
+ now: t,
25
+ customIndicator: e.edgeIndicatorFns[o],
26
+ resolveEdgeAnchor: () => e.resolveEdgeAnchor(o, l),
26
27
  resolveEdgeBarSpacing: () => e.resolveEdgeBarSpacing(),
27
- reportPlaceholders: (a) => e.reportPlaceholders(t, a)
28
- }), n < 1 && c.restore();
28
+ reportPlaceholders: (a) => e.reportPlaceholders(o, a)
29
+ }), n < 1 && i.restore();
29
30
  }
30
31
  }
31
- function g(e, o, t) {
32
- return o !== null ? o : e === "left" ? t.first ?? null : t.last ?? null;
32
+ function u(e, t, o) {
33
+ return t !== null ? t : e === "left" ? o.first ?? null : o.last ?? null;
33
34
  }
34
- function u(e, o) {
35
- return "close" in o ? e === "left" ? o.open : o.close : o.value;
35
+ function f(e, t) {
36
+ return "close" in t ? e === "left" ? t.open : t.close : c(t);
36
37
  }
37
38
  export {
38
- d as drawEdgeIndicators,
39
- u as resolveEdgeAnchorValue,
40
- g as resolveEdgeBoundary
39
+ h as drawEdgeIndicators,
40
+ f as resolveEdgeAnchorValue,
41
+ u as resolveEdgeBoundary
41
42
  };