@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,14 +1,14 @@
1
1
  import { DEFAULT_HISTORY_REVEAL as nt, DEFAULT_LINE_INTRO as lt, DEFAULT_LINE_PULSE as at, DEFAULT_LINE_SMOOTH as rt, DEFAULT_LINE_ENTRY as ht } from "../animation/config.js";
2
- import { easeOutCubic as U } from "../animation/easing.js";
2
+ import { easeOutCubic as $ } from "../animation/easing.js";
3
3
  import { decimateLineData as q } from "../data/decimation.js";
4
4
  import { hexToRgba as X } from "../utils/color.js";
5
5
  import { lerp as N } from "../utils/math.js";
6
6
  import { BaseMultiLayerSeries as ut } from "./base-multi-layer.js";
7
- import { unfoldIntro as ft, backfillSweepIntro as pt } from "./line-intro.js";
8
- import { buildCurveSegments as tt } from "./painters/canvas-path.js";
9
- import { resolveLinePainter as mt } from "./painters/resolve.js";
10
- import { ScaleStack as et } from "./scale-stack.js";
11
- const gt = {
7
+ import { unfoldIntro as ft, scaleMean as mt, backfillSweepIntro as pt } from "./line-intro.js";
8
+ import { buildCurveSegments as tt, replaySegmentsForward as et, replaySegmentsReversed as gt } from "./painters/canvas-path.js";
9
+ import { resolveLinePainter as dt } from "./painters/resolve.js";
10
+ import { ScaleStack as it } from "./scale-stack.js";
11
+ const vt = {
12
12
  colors: ["#2962FF"],
13
13
  strokeWidth: 1,
14
14
  area: { visible: !0 },
@@ -21,81 +21,62 @@ const gt = {
21
21
  introMs: lt,
22
22
  historyRevealMs: nt
23
23
  };
24
- function it(x) {
25
- const t = x.areaFill, e = t !== void 0 && x.area === void 0 ? { visible: !!t } : x.area;
24
+ function ot(y) {
25
+ const t = y.areaFill, i = t !== void 0 && y.area === void 0 ? { visible: !!t } : y.area;
26
26
  return {
27
- ...x,
28
- area: e,
29
- entryMs: x.entryMs === !1 ? 0 : x.entryMs ?? ht,
30
- smoothMs: x.smoothMs === !1 ? 0 : x.smoothMs ?? rt,
31
- pulseMs: x.pulseMs === !1 ? 0 : x.pulseMs ?? at,
32
- introMs: x.introMs === !1 ? 0 : x.introMs ?? lt,
33
- historyRevealMs: x.historyRevealMs === !1 ? 0 : x.historyRevealMs ?? nt
27
+ ...y,
28
+ area: i,
29
+ entryMs: y.entryMs === !1 ? 0 : y.entryMs ?? ht,
30
+ smoothMs: y.smoothMs === !1 ? 0 : y.smoothMs ?? rt,
31
+ pulseMs: y.pulseMs === !1 ? 0 : y.pulseMs ?? at,
32
+ introMs: y.introMs === !1 ? 0 : y.introMs ?? lt,
33
+ historyRevealMs: y.historyRevealMs === !1 ? 0 : y.historyRevealMs ?? nt
34
34
  };
35
35
  }
36
- function ot(x) {
37
- return x.map(([t, e]) => ({ x: t, y: e }));
36
+ function st(y) {
37
+ return y.map(([t, i]) => ({ x: t, y: i }));
38
38
  }
39
- const J = 0.15, dt = pt();
40
- function j(x, t, e) {
41
- const { resolve: i, lerp: o = N } = e;
42
- if (x.length === 0) return null;
43
- if (t <= x[0].time) return Number.isFinite(x[0].value) ? i(x[0]) : null;
44
- const s = x[x.length - 1];
45
- if (t >= s.time) return Number.isFinite(s.value) ? i(s) : null;
46
- let l = 0, a = x.length - 1;
47
- for (; a - l > 1; ) {
48
- const p = l + a >> 1;
49
- x[p].time <= t ? l = p : a = p;
50
- }
51
- const f = x[l], r = x[a];
52
- if (!Number.isFinite(f.value) || !Number.isFinite(r.value)) return null;
53
- const m = r.time - f.time;
54
- return m <= 0 ? i(f) : o(i(f), i(r), (t - f.time) / m);
39
+ const J = 0.15, xt = pt();
40
+ function j(y, t, i) {
41
+ const { resolve: e, lerp: o = N } = i;
42
+ if (y.length === 0) return null;
43
+ if (t <= y[0].time) return Number.isFinite(y[0].value) ? e(y[0]) : null;
44
+ const s = y[y.length - 1];
45
+ if (t >= s.time) return Number.isFinite(s.value) ? e(s) : null;
46
+ let l = 0, r = y.length - 1;
47
+ for (; r - l > 1; ) {
48
+ const c = l + r >> 1;
49
+ y[c].time <= t ? l = c : r = c;
50
+ }
51
+ const f = y[l], h = y[r];
52
+ if (!Number.isFinite(f.value) || !Number.isFinite(h.value)) return null;
53
+ const m = h.time - f.time;
54
+ return m <= 0 ? e(f) : o(e(f), e(h), (t - f.time) / m);
55
55
  }
56
- function xt(x, t) {
57
- const e = t.getTransform();
58
- let i = 0, o = 0;
59
- for (const l of x)
60
- t.isPlottable(l.value) && (i += e === null ? l.value : e.forward(l.value), o++);
61
- if (o === 0) return null;
62
- const s = i / o;
63
- return e === null ? s : e.inverse(s);
64
- }
65
- function vt(x, t) {
66
- let e = 0, i = x.length - 1;
67
- for (; e <= i; ) {
68
- const o = e + i >> 1;
69
- if (x[o] === t) return o;
70
- x[o] < t ? e = o + 1 : i = o - 1;
56
+ function yt(y, t) {
57
+ let i = 0, e = y.length - 1;
58
+ for (; i <= e; ) {
59
+ const o = i + e >> 1;
60
+ if (y[o] === t) return o;
61
+ y[o] < t ? i = o + 1 : e = o - 1;
71
62
  }
72
63
  return -1;
73
64
  }
74
- function st(x, t) {
75
- for (const e of t)
76
- e.kind === "line" ? x.lineTo(e.x, e.y) : x.bezierCurveTo(e.cp1x, e.cp1y, e.cp2x, e.cp2y, e.x, e.y);
77
- }
78
- function yt(x, t, e) {
79
- for (let i = e.length - 1; i >= 0; i--) {
80
- const o = e[i], s = i > 0 ? e[i - 1] : t[0];
81
- o.kind === "line" ? x.lineTo(s.x, s.y) : x.bezierCurveTo(o.cp2x, o.cp2y, o.cp1x, o.cp1y, s.x, s.y);
82
- }
83
- }
84
- class bt extends ut {
65
+ class Pt extends ut {
85
66
  kind = "line";
86
67
  areaGradientCache = /* @__PURE__ */ new Map();
87
- constructor(t, e) {
88
- super(t), this.options = it({ ...gt, ...e });
68
+ constructor(t, i) {
69
+ super(t), this.options = ot({ ...vt, ...i });
89
70
  }
90
71
  updateOptions(t) {
91
- this.options = it({ ...this.options, ...t });
72
+ this.options = ot({ ...this.options, ...t });
92
73
  }
93
74
  getStacking() {
94
75
  return this.options.stacking;
95
76
  }
96
- applyTheme(t, e) {
97
- const i = this.stores.length === 1 ? [t.line.color] : t.seriesColors.slice(0, this.stores.length);
98
- this.updateOptions({ colors: i }), this.options.strokeWidth === e.line.width && this.updateOptions({ strokeWidth: t.line.width });
77
+ applyTheme(t, i) {
78
+ const e = this.stores.length === 1 ? [t.line.color] : t.seriesColors.slice(0, this.stores.length);
79
+ this.updateOptions({ colors: e }), this.options.strokeWidth === i.line.width && this.updateOptions({ strokeWidth: t.line.width });
99
80
  }
100
81
  isEntryEnabled() {
101
82
  return (this.options.entryAnimation ?? "grow") !== "none";
@@ -106,27 +87,27 @@ class bt extends ut {
106
87
  get overlayNeedsAnimation() {
107
88
  return this.hasPulse;
108
89
  }
109
- hasOverlayContentInRange(t, e) {
110
- for (let i = 0; i < this.stores.length; i++) {
111
- if (this.getLayerAlpha(i) <= 0) continue;
112
- const o = this.stores[i].last();
90
+ hasOverlayContentInRange(t, i) {
91
+ for (let e = 0; e < this.stores.length; e++) {
92
+ if (this.getLayerAlpha(e) <= 0) continue;
93
+ const o = this.stores[e].last();
113
94
  if (o && o.time >= t) return !0;
114
95
  }
115
96
  return !1;
116
97
  }
117
98
  render(t) {
118
99
  this.tickAnimations(performance.now()), this.lastYScale = t.yScale;
119
- const { context: e } = t.scope;
100
+ const { context: i } = t.scope;
120
101
  this.historyDirectives = null;
121
- const i = this.historyRange;
122
- if (this.historyWave.active && i !== null) {
123
- const a = this.options.historyReveal ?? dt;
124
- a !== "none" && (this.historyDirectives = a(this.buildHistoryFrame(t, i)));
102
+ const e = this.historyRange;
103
+ if (this.historyWave.active && e !== null) {
104
+ const r = this.options.historyReveal ?? xt;
105
+ r !== "none" && (this.historyDirectives = r(this.buildHistoryFrame(t, e)));
125
106
  }
126
107
  const o = this.historyDirectives, s = o?.ghostAlpha ?? 0;
127
- s > 0 && (e.save(), e.globalAlpha *= s, this.introGhostPass = !0, this.renderBody(t), this.introGhostPass = !1, e.restore());
128
- const l = this.applyHistoryClip(t, o, i);
129
- this.introWave.active ? this.renderWithIntro(t) : (this.introDirectives = null, this.renderBody(t)), l && e.restore(), o?.heads !== void 0 && o.heads.length > 0 && this.drawIntroHeads(t, o.heads, this.historyWave.linear());
108
+ s > 0 && (i.save(), i.globalAlpha *= s, this.introGhostPass = !0, this.renderBody(t), this.introGhostPass = !1, i.restore());
109
+ const l = this.applyHistoryClip(t, o, e);
110
+ this.introWave.active ? this.renderWithIntro(t) : (this.introDirectives = null, this.renderBody(t)), l && i.restore(), o?.heads !== void 0 && o.heads.length > 0 && this.drawIntroHeads(t, o.heads, this.historyWave.linear());
130
111
  }
131
112
  /**
132
113
  * Initial-load intro pass: the resolved LineIntroFn describes this frame
@@ -134,16 +115,16 @@ class bt extends ut {
134
115
  * renderer executes the directives around the untouched body pass.
135
116
  */
136
117
  renderWithIntro(t) {
137
- const e = this.resolveIntro()(this.buildIntroFrame(t));
138
- this.introDirectives = e;
139
- const { context: i } = t.scope, { width: o, height: s } = t.scope.bitmapSize, l = e.ghostAlpha ?? 0;
140
- l > 0 && (i.save(), i.globalAlpha *= l, this.introGhostPass = !0, this.renderBody(t), this.introGhostPass = !1, i.restore());
141
- const a = e.clip, f = a !== void 0 && (a.fromX !== void 0 || a.toX !== void 0);
118
+ const i = this.resolveIntro()(this.buildIntroFrame(t));
119
+ this.introDirectives = i;
120
+ const { context: e } = t.scope, { width: o, height: s } = t.scope.bitmapSize, l = i.ghostAlpha ?? 0;
121
+ l > 0 && (e.save(), e.globalAlpha *= l, this.introGhostPass = !0, this.renderBody(t), this.introGhostPass = !1, e.restore());
122
+ const r = i.clip, f = r !== void 0 && (r.fromX !== void 0 || r.toX !== void 0);
142
123
  if (f) {
143
- const r = a.fromX ?? 0, m = a.toX ?? o;
144
- i.save(), i.beginPath(), i.rect(r, 0, Math.max(0, m - r), s), i.clip();
124
+ const h = r.fromX ?? 0, m = r.toX ?? o;
125
+ e.save(), e.beginPath(), e.rect(h, 0, Math.max(0, m - h), s), e.clip();
145
126
  }
146
- this.renderBody(t), f && i.restore(), e.heads !== void 0 && e.heads.length > 0 && this.drawIntroHeads(t, e.heads, this.introWave.linear());
127
+ this.renderBody(t), f && e.restore(), i.heads !== void 0 && i.heads.length > 0 && this.drawIntroHeads(t, i.heads, this.introWave.linear());
147
128
  }
148
129
  /**
149
130
  * Apply the history reveal's clip directive, mapped from reveal space
@@ -151,11 +132,11 @@ class bt extends ut {
151
132
  * to bitmap space. Everything at or after the boundary always draws; a
152
133
  * small pad keeps the stroke cap at the reveal front from being shaved.
153
134
  */
154
- applyHistoryClip(t, e, i) {
155
- const o = e?.clip;
156
- if (o === void 0 || i === null || o.fromX === void 0 && o.toX === void 0) return !1;
157
- const { context: s } = t.scope, { width: l, height: a } = t.scope.bitmapSize, f = t.timeScale.timeToBitmapXExact(i.to), r = Math.abs(f - t.timeScale.timeToBitmapXExact(i.from)), m = Math.max(2, (this.options.strokeWidth ?? 1) * t.scope.horizontalPixelRatio), p = o.fromX ?? 0, v = o.toX ?? r;
158
- return s.save(), s.beginPath(), s.rect(f - v - m, 0, Math.max(0, v - p + m), a), s.rect(f, 0, Math.max(0, l - f), a), s.clip(), !0;
135
+ applyHistoryClip(t, i, e) {
136
+ const o = i?.clip;
137
+ if (o === void 0 || e === null || o.fromX === void 0 && o.toX === void 0) return !1;
138
+ const { context: s } = t.scope, { width: l, height: r } = t.scope.bitmapSize, f = t.timeScale.timeToBitmapXExact(e.to), h = Math.abs(f - t.timeScale.timeToBitmapXExact(e.from)), m = Math.max(2, (this.options.strokeWidth ?? 1) * t.scope.horizontalPixelRatio), c = o.fromX ?? 0, x = o.toX ?? h;
139
+ return s.save(), s.beginPath(), s.rect(f - x - m, 0, Math.max(0, x - c + m), r), s.rect(f, 0, Math.max(0, l - f), r), s.clip(), !0;
159
140
  }
160
141
  renderBody(t) {
161
142
  this.options.stacking === "off" ? (this.stackedEdges = null, this.renderOff(t)) : this.renderStacked(t, this.options.stacking === "percent");
@@ -207,55 +188,55 @@ class bt extends ut {
207
188
  * accessors are scoped to that span — `layerMean` anchors an unfold to
208
189
  * the new history, not the whole window.
209
190
  */
210
- buildHistoryFrame(t, e) {
191
+ buildHistoryFrame(t, i) {
211
192
  return this.buildFrame(t, {
212
193
  progress: this.historyWave.linear(),
213
- range: e,
194
+ range: i,
214
195
  width: Math.abs(
215
- t.timeScale.timeToBitmapXExact(e.to) - t.timeScale.timeToBitmapXExact(e.from)
196
+ t.timeScale.timeToBitmapXExact(i.to) - t.timeScale.timeToBitmapXExact(i.from)
216
197
  )
217
198
  });
218
199
  }
219
- buildFrame(t, e) {
220
- const { timeScale: i, yScale: o, scope: s } = t, { progress: l, range: a, width: f } = e, r = new Array(this.stores.length), m = new Array(this.stores.length);
221
- let p;
222
- const v = (n) => {
223
- let u = r[n];
224
- return u === void 0 && (u = this.stores[n]?.getVisibleData(a.from, a.to) ?? [], r[n] = u), u;
200
+ buildFrame(t, i) {
201
+ const { timeScale: e, yScale: o, scope: s } = t, { progress: l, range: r, width: f } = i, h = this.options.stacking === "percent", m = new Array(this.stores.length), c = new Array(this.stores.length);
202
+ let x, n;
203
+ const p = (a) => {
204
+ let g = m[a];
205
+ return g === void 0 && (g = this.stores[a]?.getVisibleData(r.from, r.to) ?? [], m[a] = g), g;
225
206
  };
226
207
  return {
227
208
  progress: l,
228
- range: a,
209
+ range: r,
229
210
  width: f,
230
211
  height: o.getMediaHeight() * s.verticalPixelRatio,
231
212
  stacking: this.options.stacking,
232
- timeToX: (n) => i.timeToBitmapXExact(n),
233
- xToTime: (n) => i.xToTime(n / s.horizontalPixelRatio),
234
- valueToY: (n) => o.valueToBitmapYExact(n),
235
- lerpValue: (n, u, c) => o.lerpValue(n, u, c),
213
+ timeToX: (a) => e.timeToBitmapXExact(a),
214
+ xToTime: (a) => e.xToTime(a / s.horizontalPixelRatio),
215
+ valueToY: (a) => o.valueToBitmapYExact(a),
216
+ lerpValue: (a, g, A) => o.lerpValue(a, g, A),
236
217
  layerCount: this.stores.length,
237
- layerData: v,
238
- layerMean: (n) => {
239
- let u = m[n];
240
- return u === void 0 && (u = xt(v(n), o), m[n] = u), u;
218
+ layerData: p,
219
+ layerMean: (a) => {
220
+ let g = c[a];
221
+ return g === void 0 && (h ? (x ??= this.meanShares(p, o), g = x[a]) : g = mt(p(a), o), c[a] = g), g;
241
222
  },
242
223
  primaryPath: () => {
243
- if (p === void 0) {
244
- p = null;
245
- for (let n = 0; n < this.stores.length; n++) {
246
- if (this.getLayerAlpha(n) <= 0 || !this.stores[n].isVisible()) continue;
247
- const u = v(n).filter((c) => o.isPlottable(c.value));
248
- if (!(u.length < 2)) {
249
- p = u.map((c) => ({
250
- x: i.timeToBitmapXExact(c.time),
251
- y: o.valueToBitmapYExact(c.value),
252
- time: c.time
224
+ if (n === void 0) {
225
+ n = null;
226
+ for (let a = 0; a < this.stores.length; a++) {
227
+ if (this.getLayerAlpha(a) <= 0 || !this.stores[a].isVisible()) continue;
228
+ const g = p(a).filter((A) => o.isPlottable(A.value));
229
+ if (!(g.length < 2)) {
230
+ n = g.map((A) => ({
231
+ x: e.timeToBitmapXExact(A.time),
232
+ y: o.valueToBitmapYExact(A.value),
233
+ time: A.time
253
234
  }));
254
235
  break;
255
236
  }
256
237
  }
257
238
  }
258
- return p;
239
+ return n;
259
240
  }
260
241
  };
261
242
  }
@@ -265,16 +246,59 @@ class bt extends ut {
265
246
  * overlay pulse) already flows through `effectiveValue`, so one override
266
247
  * animates the whole geometry.
267
248
  */
268
- effectiveValue(t, e, i, o) {
269
- const s = super.effectiveValue(t, e, i, o), l = this.historyWave.active ? this.historyDirectives?.value : void 0, a = this.historyRange;
270
- if (l !== void 0 && a !== null && i < a.to) {
271
- const v = a.to - a.from, n = v > 0 ? Math.min(1, Math.max(0, (a.to - i) / v)) : 0;
272
- return l({ layerIndex: e, time: i, value: s, position: n });
249
+ effectiveValue(t, i, e, o) {
250
+ const s = super.effectiveValue(t, i, e, o);
251
+ return this.options.stacking === "percent" ? s : this.introValue(t, { layerIndex: i, time: e, value: s });
252
+ }
253
+ /** Layer's share of its column in percent, passed through the intro value transform. */
254
+ introShare(t, i) {
255
+ const { layerIndex: e, time: o, value: s, total: l } = i;
256
+ if (l <= 0) return s;
257
+ const r = s / l * 100;
258
+ return Math.max(0, this.introValue(t, { layerIndex: e, time: o, value: r }));
259
+ }
260
+ /**
261
+ * What `layerMean` reports on a percent stack: each layer's mean share over
262
+ * the shared columns, alpha-weighted like the stacked pass, or `null` when it has none.
263
+ * A layer counts 0 where it has no sample yet, so the means sum to 100.
264
+ */
265
+ meanShares(t, i) {
266
+ const e = this.stores.length, o = /* @__PURE__ */ new Set();
267
+ for (let h = 0; h < e; h++)
268
+ for (const m of t(h))
269
+ o.add(m.time);
270
+ const s = new Array(e).fill(0), l = new Array(e).fill(!1), r = new Array(e);
271
+ let f = 0;
272
+ for (const h of o) {
273
+ let m = 0;
274
+ for (let c = 0; c < e; c++) {
275
+ r[c] = null;
276
+ const x = this.getLayerAlpha(c), n = t(c);
277
+ if (x <= 0 || n.length === 0 || h < n[0].time) continue;
278
+ const p = j(n, h, { resolve: (a) => a.value });
279
+ p === null || !i.isPlottable(p) || (r[c] = p * x, m += p * x);
280
+ }
281
+ if (!(m <= 0)) {
282
+ f++;
283
+ for (let c = 0; c < e; c++) {
284
+ const x = r[c];
285
+ x !== null && (s[c] += x / m * 100, l[c] = !0);
286
+ }
287
+ }
288
+ }
289
+ return s.map((h, m) => l[m] ? h / f : null);
290
+ }
291
+ /** The active history-reveal or intro value transform applied to one value. */
292
+ introValue(t, i) {
293
+ const { layerIndex: e, time: o, value: s } = i, l = this.historyWave.active ? this.historyDirectives?.value : void 0, r = this.historyRange;
294
+ if (l !== void 0 && r !== null && o < r.to) {
295
+ const x = r.to - r.from, n = x > 0 ? Math.min(1, Math.max(0, (r.to - o) / x)) : 0;
296
+ return l({ layerIndex: e, time: o, value: s, position: n });
273
297
  }
274
298
  const f = this.introWave.active ? this.introDirectives?.value : void 0;
275
299
  if (f === void 0) return s;
276
- const r = t.timeScale.getRange(), m = r.to - r.from, p = m > 0 ? Math.min(1, Math.max(0, (i - r.from) / m)) : 0;
277
- return f({ layerIndex: e, time: i, value: s, position: p });
300
+ const h = t.timeScale.getRange(), m = h.to - h.from, c = m > 0 ? Math.min(1, Math.max(0, (o - h.from) / m)) : 0;
301
+ return f({ layerIndex: e, time: o, value: s, position: c });
278
302
  }
279
303
  /**
280
304
  * Extends the base last-value query with the 'grow' entrance's value-space
@@ -284,36 +308,36 @@ class bt extends ut {
284
308
  * this, a tooltip/YLabel query would report a freshly-appended point's raw
285
309
  * value the instant it lands, `entryMs` before the marker visually arrives there.
286
310
  */
287
- snapshotValue(t, e, i) {
288
- const o = super.snapshotValue(t, e, i);
289
- return (this.options.entryAnimation ?? "grow") !== "grow" ? o : this.chainedTailValues(t)?.get(e) ?? o;
311
+ snapshotValue(t, i, e) {
312
+ const o = super.snapshotValue(t, i, e);
313
+ return (this.options.entryAnimation ?? "grow") !== "grow" ? o : this.chainedTailValues(t)?.get(i) ?? o;
290
314
  }
291
315
  /**
292
316
  * Value-space counterpart of {@link chainedTailPositions} — see {@link snapshotValue}.
293
317
  * `resolve` lets the stacked renderer feed its ctx-aware `effectiveValue`
294
318
  * in; query paths, which have no render context, keep the `liveValue` default.
295
319
  */
296
- chainedTailValues(t, e = (i, o) => this.liveValue(t, i, o)) {
297
- const i = this.unsettledTail(t);
298
- if (i.length === 0) return null;
299
- const o = this.stores[t].getAll(), s = o.length - 1 - i.length;
320
+ chainedTailValues(t, i = (e, o) => this.liveValue(t, e, o)) {
321
+ const e = this.unsettledTail(t);
322
+ if (e.length === 0) return null;
323
+ const o = this.stores[t].getAll(), s = o.length - 1 - e.length;
300
324
  if (s < 0) return null;
301
325
  const l = o[s];
302
326
  if (!Number.isFinite(l.value)) return null;
303
- let a = e(l.time, l.value);
327
+ let r = i(l.time, l.value);
304
328
  const f = /* @__PURE__ */ new Map();
305
- for (let r = 0; r < i.length; r++) {
306
- const m = o[s + 1 + r];
329
+ for (let h = 0; h < e.length; h++) {
330
+ const m = o[s + 1 + h];
307
331
  if (!Number.isFinite(m.value)) return null;
308
- const p = U(i[r].progress), v = e(m.time, m.value), n = this.axisLerp(a, v, p);
309
- f.set(m.time, n), a = n;
332
+ const c = $(e[h].progress), x = i(m.time, m.value), n = this.axisLerp(r, x, c);
333
+ f.set(m.time, n), r = n;
310
334
  }
311
335
  return f;
312
336
  }
313
337
  /** `lerp` along the last rendered Y axis — plain before the first render. */
314
- axisLerp(t, e, i) {
338
+ axisLerp(t, i, e) {
315
339
  const o = this.lastYScale;
316
- return o === null ? N(t, e, i) : o.lerpValue(t, e, i);
340
+ return o === null ? N(t, i, e) : o.lerpValue(t, i, e);
317
341
  }
318
342
  /**
319
343
  * Glowing pulse dots riding the intro's head anchors — the line reads as
@@ -321,23 +345,23 @@ class bt extends ut {
321
345
  * the reveal lands. Off-mode only: recomputing the stacked cumulative at
322
346
  * an arbitrary head time isn't worth it for a one-second decoration.
323
347
  */
324
- drawIntroHeads(t, e, i) {
348
+ drawIntroHeads(t, i, e) {
325
349
  if (this.options.stacking !== "off") return;
326
- const o = Math.min(1, i / J), s = Math.min(1, (1 - i) / J), l = Math.max(0, Math.min(o, s));
350
+ const o = Math.min(1, e / J), s = Math.min(1, (1 - e) / J), l = Math.max(0, Math.min(o, s));
327
351
  if (l <= 0) return;
328
- const { scope: a } = t;
329
- for (const f of e)
330
- for (let r = 0; r < this.stores.length; r++) {
331
- const m = this.getLayerAlpha(r);
332
- if (m <= 0 || !this.stores[r].isVisible()) continue;
333
- const p = this.introHeadAnchor(t, r, f);
334
- p !== null && this.drawPulse({
335
- ctx: a.context,
336
- x: p.x,
337
- y: p.y,
338
- color: this.resolveLayerColor(r, p.value),
339
- pixelRatio: a.horizontalPixelRatio,
340
- phase: i * 2,
352
+ const { scope: r } = t;
353
+ for (const f of i)
354
+ for (let h = 0; h < this.stores.length; h++) {
355
+ const m = this.getLayerAlpha(h);
356
+ if (m <= 0 || !this.stores[h].isVisible()) continue;
357
+ const c = this.introHeadAnchor(t, h, f);
358
+ c !== null && this.drawPulse({
359
+ ctx: r.context,
360
+ x: c.x,
361
+ y: c.y,
362
+ color: this.resolveLayerColor(h, c.value),
363
+ pixelRatio: r.horizontalPixelRatio,
364
+ phase: e * 2,
341
365
  alpha: l * m
342
366
  });
343
367
  }
@@ -353,31 +377,31 @@ class bt extends ut {
353
377
  * right-padding region beyond the line's end (the sweep front travels the
354
378
  * visible range, not the data span) and jumps back on settle.
355
379
  */
356
- introHeadAnchor(t, e, i) {
357
- const { timeScale: o, yScale: s } = t, l = o.getRange(), a = this.stores[e].getVisibleData(l.from, l.to);
358
- if (a.length === 0) return null;
359
- const f = this.stores[e].last();
360
- if (f !== void 0 && i.time >= f.time) {
380
+ introHeadAnchor(t, i, e) {
381
+ const { timeScale: o, yScale: s } = t, l = o.getRange(), r = this.stores[i].getVisibleData(l.from, l.to);
382
+ if (r.length === 0) return null;
383
+ const f = this.stores[i].last();
384
+ if (f !== void 0 && e.time >= f.time) {
361
385
  if (!s.isPlottable(f.value)) return null;
362
- const p = this.trailingEndpoint(t, e);
363
- return p === null ? null : { x: p.x, y: p.y, value: f.value };
386
+ const c = this.trailingEndpoint(t, i);
387
+ return c === null ? null : { x: c.x, y: c.y, value: f.value };
364
388
  }
365
- const r = a[0];
366
- if (i.time <= r.time) {
367
- if (!s.isPlottable(r.value)) return null;
368
- const p = this.effectiveValue(t, e, r.time, r.value);
389
+ const h = r[0];
390
+ if (e.time <= h.time) {
391
+ if (!s.isPlottable(h.value)) return null;
392
+ const c = this.effectiveValue(t, i, h.time, h.value);
369
393
  return {
370
- x: o.timeToBitmapXExact(r.time),
371
- y: s.valueToBitmapYExact(p),
372
- value: r.value
394
+ x: o.timeToBitmapXExact(h.time),
395
+ y: s.valueToBitmapYExact(c),
396
+ value: h.value
373
397
  };
374
398
  }
375
- const m = j(a, i.time, {
376
- resolve: (p) => this.effectiveValue(t, e, p.time, p.value),
399
+ const m = j(r, e.time, {
400
+ resolve: (c) => this.effectiveValue(t, i, c.time, c.value),
377
401
  // Along the axis, so the dot stays on the straight segment the stroke draws.
378
- lerp: (p, v, n) => !s.isPlottable(p) || !s.isPlottable(v) ? Number.NaN : s.lerpValue(p, v, n)
402
+ lerp: (c, x, n) => !s.isPlottable(c) || !s.isPlottable(x) ? Number.NaN : s.lerpValue(c, x, n)
379
403
  });
380
- return m === null || !s.isPlottable(m) ? null : { x: i.x, y: s.valueToBitmapYExact(m), value: m };
404
+ return m === null || !s.isPlottable(m) ? null : { x: e.x, y: s.valueToBitmapYExact(m), value: m };
381
405
  }
382
406
  /**
383
407
  * Rendered positions of the layer's still-unsettled trailing points, keyed
@@ -401,44 +425,52 @@ class bt extends ut {
401
425
  * lagging sibling shouldn't zero out the moment another layer ticks past
402
426
  * it (see `renderStacked`'s `valueMaps` comment for the full rationale).
403
427
  */
404
- stackedValueAt(t, e, i) {
405
- const o = this.options.stacking === "percent", s = (this.options.entryAnimation ?? "grow") === "grow", l = new Array(this.stores.length), a = (n) => {
428
+ stackedValueAt(t, i, e) {
429
+ const o = this.options.stacking === "percent", s = (this.options.entryAnimation ?? "grow") === "grow", l = new Array(this.stores.length), r = (n) => {
406
430
  if (!s) return null;
407
- const u = l[n];
408
- if (u !== void 0) return u;
409
- const c = this.chainedTailValues(n, (y, k) => this.effectiveValue(t, n, y, k));
410
- return l[n] = c, c;
431
+ const p = l[n];
432
+ if (p !== void 0) return p;
433
+ const a = this.chainedTailValues(n, (g, A) => this.effectiveValue(t, n, g, A));
434
+ return l[n] = a, a;
411
435
  }, f = (n) => {
412
- const u = this.stores[n].getAll();
413
- if (u.length === 0 || i < u[0].time) return null;
414
- const c = a(n);
415
- return j(u, i, {
416
- resolve: (y) => c?.get(y.time) ?? this.effectiveValue(t, n, y.time, y.value)
436
+ const p = this.stores[n].getAll();
437
+ if (p.length === 0 || e < p[0].time) return null;
438
+ const a = r(n);
439
+ return j(p, e, {
440
+ resolve: (g) => a?.get(g.time) ?? this.effectiveValue(t, n, g.time, g.value)
417
441
  });
418
- }, { yScale: r } = t;
419
- if (r.getTransform() !== null && !o) {
420
- const n = new et(r);
421
- for (let u = 0; u <= e; u++) {
422
- const c = this.getLayerAlpha(u), y = c > 0 ? f(u) : null;
423
- y !== null && r.isPlottable(y) && n.push(y, c);
442
+ }, { yScale: h } = t;
443
+ if (h.getTransform() !== null && !o) {
444
+ const n = new it(h);
445
+ for (let p = 0; p <= i; p++) {
446
+ const a = this.getLayerAlpha(p), g = a > 0 ? f(p) : null;
447
+ g !== null && h.isPlottable(g) && n.push(g, a);
424
448
  }
425
449
  return n.edge;
426
450
  }
427
451
  const m = (n) => {
428
- const u = this.getLayerAlpha(n);
429
- if (u <= 0) return 0;
430
- const c = f(n);
431
- return c === null ? 0 : c * u;
452
+ const p = this.getLayerAlpha(n);
453
+ if (p <= 0) return null;
454
+ const a = this.stores[n].getAll();
455
+ if (o && a.length > 0 && e < a[0].time) return 0;
456
+ const g = f(n);
457
+ return g === null ? null : g * p;
432
458
  };
433
- let p = 0;
459
+ let c = 0;
434
460
  if (o)
435
- for (let n = 0; n < this.stores.length; n++) p += m(n);
436
- let v = 0;
437
- for (let n = 0; n <= e; n++) {
438
- const u = m(n);
439
- v += o && p > 0 ? u / p * 100 : u;
461
+ for (let n = 0; n < this.stores.length; n++)
462
+ c += m(n) ?? 0;
463
+ let x = 0;
464
+ for (let n = 0; n <= i; n++) {
465
+ const p = m(n);
466
+ if (p !== null)
467
+ if (o) {
468
+ const a = this.introShare(t, { layerIndex: n, time: e, value: p, total: c });
469
+ x = Math.min(100, x + a);
470
+ } else
471
+ x += p;
440
472
  }
441
- return v;
473
+ return x;
442
474
  }
443
475
  /**
444
476
  * Bitmap position for layer `li`'s stacked boundary at time `t`.
@@ -451,46 +483,46 @@ class bt extends ut {
451
483
  * feed. Falls back to the raw settled position off-column (decimated
452
484
  * history, or before the first stacked frame).
453
485
  */
454
- stackedPositionAt(t, e, i) {
455
- const o = this.paintedStackVertex(t, e, i);
486
+ stackedPositionAt(t, i, e) {
487
+ const o = this.paintedStackVertex(t, i, e);
456
488
  if (o !== null) return o;
457
- const { timeScale: s, yScale: l } = t, a = l.valueToBitmapYExact(this.stackedValueAt(t, e, i)), f = s.timeToBitmapXExact(i), r = this.unsettledTail(e), m = this.stores[e].getAll(), p = m.length - 1 - r.length;
458
- if ((this.options.entryAnimation ?? "grow") !== "grow" || i !== m[m.length - 1]?.time || r.length === 0 || p < 0) return { x: f, y: a };
459
- let v = s.timeToBitmapXExact(m[p].time);
460
- for (let n = 0; n < r.length; n++)
461
- v = N(v, s.timeToBitmapXExact(m[p + 1 + n].time), U(r[n].progress));
462
- return { x: v, y: a };
489
+ const { timeScale: s, yScale: l } = t, r = l.valueToBitmapYExact(this.stackedValueAt(t, i, e)), f = s.timeToBitmapXExact(e), h = this.unsettledTail(i), m = this.stores[i].getAll(), c = m.length - 1 - h.length;
490
+ if ((this.options.entryAnimation ?? "grow") !== "grow" || e !== m[m.length - 1]?.time || h.length === 0 || c < 0) return { x: f, y: r };
491
+ let x = s.timeToBitmapXExact(m[c].time);
492
+ for (let n = 0; n < h.length; n++)
493
+ x = N(x, s.timeToBitmapXExact(m[c + 1 + n].time), $(h[n].progress));
494
+ return { x, y: r };
463
495
  }
464
496
  /** Upper-edge vertex of layer `li` at column `t`, replayed from the last
465
497
  * stacked frame's data-space record against `ctx`'s scales. */
466
- paintedStackVertex(t, e, i) {
467
- const o = this.stackedEdges, s = o?.cumulative[e];
498
+ paintedStackVertex(t, i, e) {
499
+ const o = this.stackedEdges, s = o?.cumulative[i];
468
500
  if (o === null || s === void 0) return null;
469
- const { times: l, growChain: a, collapse: f } = o, r = vt(l, i);
470
- if (r < 0) return null;
471
- const { timeScale: m, yScale: p } = t, v = t.scope.bitmapSize.height, n = f[e] ?? 1, u = p.valueToBitmapYExact(s[r]), c = n >= 1 ? u : v + (u - v) * n, y = l.length - a.length;
472
- if (r < y) return { x: m.timeToBitmapXExact(i), y: c };
473
- let k = m.timeToBitmapXExact(l[y - 1]);
474
- for (let w = 0; w <= r - y; w++)
475
- k = N(k, m.timeToBitmapXExact(l[y + w]), a[w]);
476
- return { x: k, y: c };
477
- }
478
- chainedTailPositions(t, e) {
479
- const i = this.unsettledTail(e);
480
- if (i.length === 0) return null;
481
- const o = this.stores[e].getAll(), s = o.length - 1 - i.length;
501
+ const { times: l, growChain: r, collapse: f } = o, h = yt(l, e);
502
+ if (h < 0) return null;
503
+ const { timeScale: m, yScale: c } = t, x = t.scope.bitmapSize.height, n = f[i] ?? 1, p = c.valueToBitmapYExact(s[h]), a = n >= 1 ? p : x + (p - x) * n, g = l.length - r.length;
504
+ if (h < g) return { x: m.timeToBitmapXExact(e), y: a };
505
+ let A = m.timeToBitmapXExact(l[g - 1]);
506
+ for (let E = 0; E <= h - g; E++)
507
+ A = N(A, m.timeToBitmapXExact(l[g + E]), r[E]);
508
+ return { x: A, y: a };
509
+ }
510
+ chainedTailPositions(t, i) {
511
+ const e = this.unsettledTail(i);
512
+ if (e.length === 0) return null;
513
+ const o = this.stores[i].getAll(), s = o.length - 1 - e.length;
482
514
  if (s < 0) return null;
483
- const { timeScale: l, yScale: a } = t, f = o[s];
484
- if (!a.isPlottable(f.value)) return null;
485
- let r = l.timeToBitmapXExact(f.time), m = a.valueToBitmapYExact(this.effectiveValue(t, e, f.time, f.value));
486
- const p = /* @__PURE__ */ new Map();
487
- for (let v = 0; v < i.length; v++) {
488
- const n = o[s + 1 + v];
489
- if (!a.isPlottable(n.value)) return null;
490
- const u = U(i[v].progress), c = l.timeToBitmapXExact(n.time), y = a.valueToBitmapYExact(this.effectiveValue(t, e, n.time, n.value)), k = N(r, c, u), w = N(m, y, u);
491
- p.set(n.time, { x: k, y: w }), r = k, m = w;
515
+ const { timeScale: l, yScale: r } = t, f = o[s];
516
+ if (!r.isPlottable(f.value)) return null;
517
+ let h = l.timeToBitmapXExact(f.time), m = r.valueToBitmapYExact(this.effectiveValue(t, i, f.time, f.value));
518
+ const c = /* @__PURE__ */ new Map();
519
+ for (let x = 0; x < e.length; x++) {
520
+ const n = o[s + 1 + x];
521
+ if (!r.isPlottable(n.value)) return null;
522
+ const p = $(e[x].progress), a = l.timeToBitmapXExact(n.time), g = r.valueToBitmapYExact(this.effectiveValue(t, i, n.time, n.value)), A = N(h, a, p), E = N(m, g, p);
523
+ c.set(n.time, { x: A, y: E }), h = A, m = E;
492
524
  }
493
- return p;
525
+ return c;
494
526
  }
495
527
  /**
496
528
  * Bitmap coordinates for the trailing endpoint of a layer — i.e. where the
@@ -502,11 +534,11 @@ class bt extends ut {
502
534
  * (pulse dot) so the pulse glides in sync with the trailing segment instead
503
535
  * of teleporting to the raw last.time while the line still unfurls.
504
536
  */
505
- trailingEndpoint(t, e) {
506
- const i = this.stores[e].last();
507
- if (!i) return null;
508
- const { timeScale: o, yScale: s } = t, l = o.timeToBitmapXExact(i.time), a = s.valueToBitmapYExact(this.effectiveValue(t, e, i.time, i.value));
509
- return (this.options.entryAnimation ?? "grow") !== "grow" ? { x: l, y: a } : this.chainedTailPositions(t, e)?.get(i.time) ?? { x: l, y: a };
537
+ trailingEndpoint(t, i) {
538
+ const e = this.stores[i].last();
539
+ if (!e) return null;
540
+ const { timeScale: o, yScale: s } = t, l = o.timeToBitmapXExact(e.time), r = s.valueToBitmapYExact(this.effectiveValue(t, i, e.time, e.value));
541
+ return (this.options.entryAnimation ?? "grow") !== "grow" ? { x: l, y: r } : this.chainedTailPositions(t, i)?.get(e.time) ?? { x: l, y: r };
510
542
  }
511
543
  /**
512
544
  * Vertical stroke + area gradients for `options.threshold`, pinned to the
@@ -517,13 +549,13 @@ class bt extends ut {
517
549
  * the Y-axis autoscales (and during the spike's entrance), so a cache keyed on
518
550
  * the row would miss almost every frame anyway.
519
551
  */
520
- buildThresholdPaint(t, e) {
521
- const i = this.options.threshold;
522
- if (!i) return null;
523
- const { scope: o, yScale: s } = t, { context: l } = o, a = o.bitmapSize.height, f = i.above, r = i.below ?? e, m = Math.min(1, Math.max(0, s.valueToBitmapYExact(i.value) / a)), p = Math.min(6 * o.verticalPixelRatio, a * 0.02) / a, v = Math.max(0, m - p), n = Math.min(1, m + p), u = l.createLinearGradient(0, 0, 0, a);
524
- u.addColorStop(0, f), u.addColorStop(v, f), u.addColorStop(n, r), u.addColorStop(1, r);
525
- const c = l.createLinearGradient(0, 0, 0, a);
526
- return c.addColorStop(0, X(f, 0.26)), c.addColorStop(v, X(f, 0.14)), c.addColorStop(n, X(r, 0.1)), c.addColorStop(1, X(r, 0.01)), { stroke: u, area: c };
552
+ buildThresholdPaint(t, i) {
553
+ const e = this.options.threshold;
554
+ if (!e) return null;
555
+ const { scope: o, yScale: s } = t, { context: l } = o, r = o.bitmapSize.height, f = e.above, h = e.below ?? i, m = Math.min(1, Math.max(0, s.valueToBitmapYExact(e.value) / r)), c = Math.min(6 * o.verticalPixelRatio, r * 0.02) / r, x = Math.max(0, m - c), n = Math.min(1, m + c), p = l.createLinearGradient(0, 0, 0, r);
556
+ p.addColorStop(0, f), p.addColorStop(x, f), p.addColorStop(n, h), p.addColorStop(1, h);
557
+ const a = l.createLinearGradient(0, 0, 0, r);
558
+ return a.addColorStop(0, X(f, 0.26)), a.addColorStop(x, X(f, 0.14)), a.addColorStop(n, X(h, 0.1)), a.addColorStop(1, X(h, 0.01)), { stroke: p, area: a };
527
559
  }
528
560
  /**
529
561
  * Dot markers at each data point (`options.points`). Callers pass the same
@@ -534,237 +566,245 @@ class bt extends ut {
534
566
  * the stroke.
535
567
  */
536
568
  drawPointMarkers(t) {
537
- const e = this.options.points;
538
- if (!e?.visible) return;
539
- const { context: i, points: o, pixelRatio: s, color: l } = t;
569
+ const i = this.options.points;
570
+ if (!i?.visible) return;
571
+ const { context: e, points: o, pixelRatio: s, color: l } = t;
540
572
  if (o.length === 0) return;
541
- const a = Math.max(1, (e.radius ?? 3) * s);
542
- if (!(o.length > 1 && (o[o.length - 1].x - o[0].x) / (o.length - 1) < a * 3)) {
543
- i.beginPath();
573
+ const r = Math.max(1, (i.radius ?? 3) * s);
574
+ if (!(o.length > 1 && (o[o.length - 1].x - o[0].x) / (o.length - 1) < r * 3)) {
575
+ e.beginPath();
544
576
  for (const f of o)
545
- i.moveTo(f.x + a, f.y), i.arc(f.x, f.y, a, 0, Math.PI * 2);
546
- i.fillStyle = e.color ?? l, i.fill();
577
+ e.moveTo(f.x + r, f.y), e.arc(f.x, f.y, r, 0, Math.PI * 2);
578
+ e.fillStyle = i.color ?? l, e.fill();
547
579
  }
548
580
  }
549
581
  /** Each layer drawn independently */
550
582
  renderOff(t) {
551
- const { scope: e, timeScale: i, yScale: o } = t, { context: s } = e, l = i.getRange(), { verticalPixelRatio: a } = e, f = this.options.strokeWidth > 0, r = Math.max(1, Math.round(this.options.strokeWidth * a)), m = this.options.entryAnimation ?? "grow", p = mt(this.options.linePainter ?? this.options.curve ?? "straight"), v = {
583
+ const { scope: i, timeScale: e, yScale: o } = t, { context: s } = i, l = e.getRange(), { verticalPixelRatio: r } = i, f = this.options.strokeWidth > 0, h = Math.max(1, Math.round(this.options.strokeWidth * r)), m = this.options.entryAnimation ?? "grow", c = dt(this.options.linePainter ?? this.options.curve ?? "straight"), x = {
552
584
  ctx: s,
553
585
  theme: t.theme,
554
- horizontalPixelRatio: e.horizontalPixelRatio,
555
- verticalPixelRatio: a
586
+ horizontalPixelRatio: i.horizontalPixelRatio,
587
+ verticalPixelRatio: r
556
588
  };
557
589
  for (let n = 0; n < this.stores.length; n++) {
558
- const u = this.getLayerAlpha(n);
559
- if (u <= 0) continue;
560
- let c = this.stores[n].getVisibleData(l.from, l.to);
561
- const y = e.mediaSize.width;
562
- if (c.length > y * 2 && (c = q(c, Math.round(y * 1.5))), c.length < 2) continue;
563
- const k = this.stores[n].last()?.value ?? c[c.length - 1].value, w = this.resolveLayerColor(n, k), B = this.buildThresholdPaint(t, w), L = c[c.length - 1], z = this.stores[n].last(), D = z !== void 0 && L.time === z.time, F = D ? this.entranceProgress(n, L.time) : 1, C = D && m === "fade" && F < 1, O = (D ? this.trailingEndpoint(t, n) : null) ?? {
564
- x: i.timeToBitmapXExact(L.time),
590
+ const p = this.getLayerAlpha(n);
591
+ if (p <= 0) continue;
592
+ let a = this.stores[n].getVisibleData(l.from, l.to);
593
+ const g = i.mediaSize.width;
594
+ if (a.length > g * 2 && (a = q(a, Math.round(g * 1.5))), a.length < 2) continue;
595
+ const A = this.stores[n].last()?.value ?? a[a.length - 1].value, E = this.resolveLayerColor(n, A), B = this.buildThresholdPaint(t, E), L = a[a.length - 1], D = this.stores[n].last(), Y = D !== void 0 && L.time === D.time, z = Y ? this.entranceProgress(n, L.time) : 1, I = Y && m === "fade" && z < 1, H = (Y ? this.trailingEndpoint(t, n) : null) ?? {
596
+ x: e.timeToBitmapXExact(L.time),
565
597
  y: o.valueToBitmapYExact(this.effectiveValue(t, n, L.time, L.value))
566
- }, W = O.x, I = O.y, $ = D && m === "grow" ? this.chainedTailPositions(t, n) : null, G = u < 1;
567
- (G || C) && (s.save(), G && (s.globalAlpha *= u), C && (s.globalAlpha *= F));
568
- const _ = c.length - 1, h = [];
569
- let d = null;
570
- for (let g = 0; g < _; g++) {
571
- const S = c[g].value;
598
+ }, W = H.x, C = H.y, _ = Y && m === "grow" ? this.chainedTailPositions(t, n) : null, G = p < 1;
599
+ (G || I) && (s.save(), G && (s.globalAlpha *= p), I && (s.globalAlpha *= z));
600
+ const U = a.length - 1, u = [];
601
+ let v = null;
602
+ for (let d = 0; d < U; d++) {
603
+ const S = a[d].value;
572
604
  if (!o.isPlottable(S)) {
573
- d = null;
605
+ v = null;
574
606
  continue;
575
607
  }
576
- d || (d = [], h.push(d));
577
- const M = $?.get(c[g].time);
578
- if (M)
579
- d.push({ x: M.x, y: M.y });
608
+ v || (v = [], u.push(v));
609
+ const w = _?.get(a[d].time);
610
+ if (w)
611
+ v.push({ x: w.x, y: w.y });
580
612
  else {
581
- const Y = o.valueToBitmapYExact(this.effectiveValue(t, n, c[g].time, S));
582
- d.push({ x: i.timeToBitmapXExact(c[g].time), y: Y });
613
+ const F = o.valueToBitmapYExact(this.effectiveValue(t, n, a[d].time, S));
614
+ v.push({ x: e.timeToBitmapXExact(a[d].time), y: F });
583
615
  }
584
616
  }
585
- const b = c[_]?.value, A = Number.isFinite(W) && Number.isFinite(I) && o.isPlottable(b), P = m === "grow" && F < 1;
617
+ const M = a[U]?.value, b = Number.isFinite(W) && Number.isFinite(C) && o.isPlottable(M), P = m === "grow" && z < 1;
586
618
  let T = null;
587
- if (A && (d ? (d.push({ x: W, y: I }), T = d) : h.push([{ x: W, y: I }])), f && h.some((g) => g.length >= 2)) {
619
+ if (b && (v ? (v.push({ x: W, y: C }), T = v) : u.push([{ x: W, y: C }])), f && u.some((d) => d.length >= 2)) {
588
620
  s.beginPath();
589
- for (const g of h)
590
- g.length < 2 || p(v, { points: g, color: w, lineWidth: r, closing: !1, grew: P && g === T });
591
- s.strokeStyle = B ? B.stroke : w, s.lineWidth = r, s.lineJoin = "round", s.lineCap = "round", s.stroke();
621
+ for (const d of u)
622
+ d.length < 2 || c(x, { points: d, color: E, lineWidth: h, closing: !1, grew: P && d === T });
623
+ s.strokeStyle = B ? B.stroke : E, s.lineWidth = h, s.lineJoin = "round", s.lineCap = "round", s.stroke();
592
624
  }
593
625
  if (f) {
594
- const g = Math.max(1, r / 2);
626
+ const d = Math.max(1, h / 2);
595
627
  let S = !1;
596
- for (const M of h)
597
- M.length === 1 && (S || (s.beginPath(), S = !0), s.moveTo(M[0].x + g, M[0].y), s.arc(M[0].x, M[0].y, g, 0, Math.PI * 2));
598
- S && (s.fillStyle = w, s.fill());
628
+ for (const w of u)
629
+ w.length === 1 && (S || (s.beginPath(), S = !0), s.moveTo(w[0].x + d, w[0].y), s.arc(w[0].x, w[0].y, d, 0, Math.PI * 2));
630
+ S && (s.fillStyle = E, s.fill());
599
631
  }
600
632
  if (this.options.area.visible && !this.introGhostPass) {
601
- const g = e.bitmapSize.height;
633
+ const d = i.bitmapSize.height;
602
634
  let S;
603
635
  if (B)
604
636
  S = B.area;
605
637
  else {
606
- const M = String(n), Y = this.areaGradientCache.get(M);
607
- Y && Y.bottomY === g && Y.color === w ? S = Y.gradient : (S = s.createLinearGradient(0, 0, 0, g), S.addColorStop(0, X(w, 0.12)), S.addColorStop(1, X(w, 0.01)), this.areaGradientCache.set(M, { gradient: S, bottomY: g, color: w }));
638
+ const w = String(n), F = this.areaGradientCache.get(w);
639
+ F && F.bottomY === d && F.color === E ? S = F.gradient : (S = s.createLinearGradient(0, 0, 0, d), S.addColorStop(0, X(E, 0.12)), S.addColorStop(1, X(E, 0.01)), this.areaGradientCache.set(w, { gradient: S, bottomY: d, color: E }));
608
640
  }
609
641
  s.fillStyle = S;
610
- for (const M of h)
611
- M.length < 2 || (s.beginPath(), p(v, { points: M, color: w, lineWidth: r, closing: !0, grew: P && M === T }), s.lineTo(M[M.length - 1].x, g), s.lineTo(M[0].x, g), s.closePath(), s.fill());
642
+ for (const w of u)
643
+ w.length < 2 || (s.beginPath(), c(x, { points: w, color: E, lineWidth: h, closing: !0, grew: P && w === T }), s.lineTo(w[w.length - 1].x, d), s.lineTo(w[0].x, d), s.closePath(), s.fill());
612
644
  }
613
645
  if (this.options.points?.visible) {
614
- const g = [];
615
- for (const S of h)
616
- for (const M of S) g.push(M);
617
- this.drawPointMarkers({ context: s, points: g, pixelRatio: e.horizontalPixelRatio, color: w });
646
+ const d = [];
647
+ for (const S of u)
648
+ for (const w of S) d.push(w);
649
+ this.drawPointMarkers({ context: s, points: d, pixelRatio: i.horizontalPixelRatio, color: E });
618
650
  }
619
- (C || G) && s.restore();
651
+ (I || G) && s.restore();
620
652
  }
621
653
  }
622
654
  /** Stacked area rendering */
623
- renderStacked(t, e) {
624
- const { scope: i, timeScale: o, yScale: s } = t, { context: l } = i, a = o.getRange(), { verticalPixelRatio: f } = i, r = this.options.strokeWidth > 0, m = Math.max(1, Math.round(this.options.strokeWidth * f)), p = this.options.curve ?? "straight", v = i.mediaSize.width, n = this.stores.map((h, d) => {
625
- if (this.getLayerAlpha(d) <= 0) return [];
626
- let b = h.getVisibleData(a.from, a.to);
627
- return b.length > v * 2 && (b = q(b, Math.round(v * 1.5))), b;
628
- }), u = /* @__PURE__ */ new Set();
629
- for (const h of n)
630
- for (const d of h) u.add(d.time);
631
- const c = Array.from(u).sort((h, d) => h - d);
632
- if (c.length < 2) {
655
+ renderStacked(t, i) {
656
+ const { scope: e, timeScale: o, yScale: s } = t, { context: l } = e, r = o.getRange(), { verticalPixelRatio: f } = e, h = this.options.strokeWidth > 0, m = Math.max(1, Math.round(this.options.strokeWidth * f)), c = this.options.curve ?? "straight", x = e.mediaSize.width, n = this.stores.map((u, v) => {
657
+ if (this.getLayerAlpha(v) <= 0) return [];
658
+ let M = u.getVisibleData(r.from, r.to);
659
+ return M.length > x * 2 && (M = q(M, Math.round(x * 1.5))), M;
660
+ }), p = /* @__PURE__ */ new Set();
661
+ for (const u of n)
662
+ for (const v of u) p.add(v.time);
663
+ const a = Array.from(p).sort((u, v) => u - v);
664
+ if (a.length < 2) {
633
665
  this.stackedEdges = null;
634
666
  return;
635
667
  }
636
- const y = this.options.entryAnimation ?? "grow", k = n.map((h, d) => {
637
- const b = /* @__PURE__ */ new Map();
638
- if (h.length === 0) return b;
639
- const A = h[0].time, P = y === "grow" ? this.chainedTailValues(d, (g, S) => this.effectiveValue(t, d, g, S)) : null, T = (g) => P?.get(g.time) ?? this.effectiveValue(t, d, g.time, g.value);
640
- for (const g of c) {
641
- if (g < A) continue;
642
- const S = j(h, g, { resolve: T });
643
- S !== null && b.set(g, S);
668
+ const g = this.options.entryAnimation ?? "grow", A = n.map((u, v) => {
669
+ const M = /* @__PURE__ */ new Map();
670
+ if (u.length === 0) return M;
671
+ const b = u[0].time, P = g === "grow" ? this.chainedTailValues(v, (d, S) => this.effectiveValue(t, v, d, S)) : null, T = (d) => P?.get(d.time) ?? this.effectiveValue(t, v, d.time, d.value);
672
+ for (const d of a) {
673
+ if (d < b) continue;
674
+ const S = j(u, d, { resolve: T });
675
+ S !== null && M.set(d, S);
644
676
  }
645
- return b;
646
- }), w = this.stores.map((h, d) => this.getLayerAlpha(d)), B = (h, d) => {
647
- const b = k[h].get(d);
648
- return b === void 0 ? void 0 : b * w[h];
649
- }, L = s.getTransform() !== null && !e, z = Array.from({ length: this.stores.length }, () => new Array(c.length).fill(0));
650
- for (let h = 0; h < c.length; h++) {
651
- const d = c[h];
677
+ return M;
678
+ }), E = this.stores.map((u, v) => this.getLayerAlpha(v)), B = (u, v) => {
679
+ const M = A[u].get(v);
680
+ return M === void 0 ? void 0 : M * E[u];
681
+ }, L = s.getTransform() !== null && !i, D = Array.from({ length: this.stores.length }, () => new Array(a.length).fill(0));
682
+ for (let u = 0; u < a.length; u++) {
683
+ const v = a[u];
652
684
  if (L) {
653
- const P = new et(s);
685
+ const P = new it(s);
654
686
  for (let T = 0; T < this.stores.length; T++) {
655
- const g = k[T].get(d);
656
- g !== void 0 && s.isPlottable(g) && P.push(g, w[T]), z[T][h] = P.edge;
687
+ const d = A[T].get(v);
688
+ d !== void 0 && s.isPlottable(d) && P.push(d, E[T]), D[T][u] = P.edge;
657
689
  }
658
690
  continue;
659
691
  }
660
- let b = 0;
661
- if (e)
692
+ let M = 0;
693
+ if (i)
662
694
  for (let P = 0; P < this.stores.length; P++) {
663
- const T = B(P, d);
664
- T !== void 0 && s.isPlottable(T) && (b += T);
695
+ const T = B(P, v);
696
+ T !== void 0 && s.isPlottable(T) && (M += T);
665
697
  }
666
- let A = 0;
698
+ let b = 0;
667
699
  for (let P = 0; P < this.stores.length; P++) {
668
- const T = B(P, d), g = T !== void 0 && s.isPlottable(T) ? T : 0;
669
- A += e && b > 0 ? g / b * 100 : g, z[P][h] = A;
700
+ const T = B(P, v);
701
+ let d = T !== void 0 && s.isPlottable(T) ? T : null;
702
+ const S = n[P];
703
+ if (i && S.length > 0 && v < S[0].time && (d = 0), d !== null)
704
+ if (i) {
705
+ const w = this.introShare(t, { layerIndex: P, time: v, value: d, total: M });
706
+ b = Math.min(100, b + w);
707
+ } else
708
+ b += d;
709
+ D[P][u] = b;
670
710
  }
671
711
  }
672
- const D = /* @__PURE__ */ new Map();
673
- for (let h = 0; h < c.length; h++) D.set(c[h], h);
674
- const F = new Array(this.stores.length).fill(1);
675
- for (let h = 0; h < this.stores.length; h++) {
676
- if (this.getLayerAlpha(h) <= 0) continue;
677
- const d = this.unsettledTail(h), b = d.length;
678
- if (b === 0) continue;
679
- let A = !0;
680
- for (let P = 0; P < b; P++)
681
- if (D.get(d[P].time) !== c.length - b + P) {
682
- A = !1;
712
+ const Y = /* @__PURE__ */ new Map();
713
+ for (let u = 0; u < a.length; u++) Y.set(a[u], u);
714
+ const z = new Array(this.stores.length).fill(1);
715
+ for (let u = 0; u < this.stores.length; u++) {
716
+ if (this.getLayerAlpha(u) <= 0) continue;
717
+ const v = this.unsettledTail(u), M = v.length;
718
+ if (M === 0) continue;
719
+ let b = !0;
720
+ for (let P = 0; P < M; P++)
721
+ if (Y.get(v[P].time) !== a.length - M + P) {
722
+ b = !1;
683
723
  break;
684
724
  }
685
- A && (F[h] = d[b - 1].progress);
725
+ b && (z[u] = v[M - 1].progress);
686
726
  }
687
- const C = [];
688
- if (y === "grow") {
689
- const h = n.map((d) => d.length - 1);
690
- for (let d = c.length - 1; d >= 1; d--) {
691
- const b = c[d];
692
- let A = 1, P = !1;
727
+ const I = [];
728
+ if (g === "grow") {
729
+ const u = n.map((v) => v.length - 1);
730
+ for (let v = a.length - 1; v >= 1; v--) {
731
+ const M = a[v];
732
+ let b = 1, P = !1;
693
733
  for (let T = 0; T < n.length; T++) {
694
734
  if (this.getLayerAlpha(T) <= 0) continue;
695
- const g = n[T];
696
- for (; h[T] >= 0 && g[h[T]].time > b; ) h[T]--;
697
- if (h[T] < 0 || g[h[T]].time !== b) continue;
698
- const S = this.entranceProgress(T, b);
699
- (!P || S > A) && (A = S), P = !0;
735
+ const d = n[T];
736
+ for (; u[T] >= 0 && d[u[T]].time > M; ) u[T]--;
737
+ if (u[T] < 0 || d[u[T]].time !== M) continue;
738
+ const S = this.entranceProgress(T, M);
739
+ (!P || S > b) && (b = S), P = !0;
700
740
  }
701
- if (!P || A >= 1) break;
702
- C.unshift(U(A));
741
+ if (!P || b >= 1) break;
742
+ I.unshift($(b));
703
743
  }
704
744
  }
705
- const O = (h, d) => {
706
- const b = d.length;
707
- if (!(b === 0 || h.length < b + 1))
708
- for (let A = 0; A < b; A++) {
709
- const P = h.length - b + A;
710
- h[P][0] = N(h[P - 1][0], h[P][0], d[A]);
745
+ const H = (u, v) => {
746
+ const M = v.length;
747
+ if (!(M === 0 || u.length < M + 1))
748
+ for (let b = 0; b < M; b++) {
749
+ const P = u.length - M + b;
750
+ u[P][0] = N(u[P - 1][0], u[P][0], v[b]);
711
751
  }
712
- }, W = i.bitmapSize.height;
713
- let I = -1, $ = -1;
714
- for (let h = 0; h < this.stores.length; h++)
715
- if (!(this.getLayerAlpha(h) <= 0))
716
- if (I < 0)
717
- I = h;
752
+ }, W = e.bitmapSize.height;
753
+ let C = -1, _ = -1;
754
+ for (let u = 0; u < this.stores.length; u++)
755
+ if (!(this.getLayerAlpha(u) <= 0))
756
+ if (C < 0)
757
+ C = u;
718
758
  else {
719
- $ = h;
759
+ _ = u;
720
760
  break;
721
761
  }
722
- const G = I >= 0 ? this.getLayerAlpha(I) : 1, _ = n.map((h, d) => d === I ? Math.min(1, this.getLayerAlpha(d)) : 1);
723
- for (let h = this.stores.length - 1; h >= 0; h--) {
724
- const d = this.getLayerAlpha(h);
725
- if (d <= 0) continue;
726
- const b = this.stores[h].last()?.value ?? 0, A = this.resolveLayerColor(h, b), P = h === I, T = $ >= 0 && h === $ && G < 1, g = [];
727
- for (let R = 0; R < c.length; R++) {
728
- const V = h > 0 ? s.valueToBitmapYExact(z[h - 1][R]) : W;
729
- let H = V;
730
- P ? H = W : T && (H = V + (W - V) * (1 - G)), g.push([o.timeToBitmapXExact(c[R]), H]);
762
+ const G = C >= 0 ? this.getLayerAlpha(C) : 1, U = n.map((u, v) => v === C ? Math.min(1, this.getLayerAlpha(v)) : 1);
763
+ for (let u = this.stores.length - 1; u >= 0; u--) {
764
+ const v = this.getLayerAlpha(u);
765
+ if (v <= 0) continue;
766
+ const M = this.stores[u].last()?.value ?? 0, b = this.resolveLayerColor(u, M), P = u === C, T = _ >= 0 && u === _ && G < 1, d = [];
767
+ for (let R = 0; R < a.length; R++) {
768
+ const V = u > 0 ? s.valueToBitmapYExact(D[u - 1][R]) : W;
769
+ let O = V;
770
+ P ? O = W : T && (O = V + (W - V) * (1 - G)), d.push([o.timeToBitmapXExact(a[R]), O]);
731
771
  }
732
- y === "grow" && O(g, C);
772
+ g === "grow" && H(d, I);
733
773
  const S = [];
734
- for (let R = 0; R < c.length; R++) {
735
- let V = s.valueToBitmapYExact(z[h][R]);
736
- P && d < 1 && (V = W + (V - W) * d), S.push([o.timeToBitmapXExact(c[R]), V]);
774
+ for (let R = 0; R < a.length; R++) {
775
+ let V = s.valueToBitmapYExact(D[u][R]);
776
+ P && v < 1 && (V = W + (V - W) * v), S.push([o.timeToBitmapXExact(a[R]), V]);
737
777
  }
738
- y === "grow" && O(S, C);
739
- const M = ot(S), Y = tt(M, p, y === "grow" && C.length > 0), K = y === "fade" && F[h] < 1;
740
- if (K && (l.save(), l.globalAlpha *= F[h]), this.options.area.visible && !this.introGhostPass) {
741
- let R = S[0][1], V = g[0][1];
742
- for (let E = 1; E < S.length; E++)
743
- S[E][1] < R && (R = S[E][1]);
744
- for (let E = 1; E < g.length; E++)
745
- g[E][1] > V && (V = g[E][1]);
746
- let H = X(A, 0.25);
778
+ g === "grow" && H(S, I);
779
+ const w = st(S), F = tt(w, c, g === "grow" && I.length > 0), K = g === "fade" && z[u] < 1;
780
+ if (K && (l.save(), l.globalAlpha *= z[u]), this.options.area.visible && !this.introGhostPass) {
781
+ let R = S[0][1], V = d[0][1];
782
+ for (let k = 1; k < S.length; k++)
783
+ S[k][1] < R && (R = S[k][1]);
784
+ for (let k = 1; k < d.length; k++)
785
+ d[k][1] > V && (V = d[k][1]);
786
+ let O = X(b, 0.25);
747
787
  if (V > R + 0.5) {
748
- const E = l.createLinearGradient(0, R, 0, V);
749
- E.addColorStop(0, X(A, 0.25)), E.addColorStop(1, X(A, 0.05)), H = E;
788
+ const k = l.createLinearGradient(0, R, 0, V);
789
+ k.addColorStop(0, X(b, 0.25)), k.addColorStop(1, X(b, 0.05)), O = k;
750
790
  }
751
- if (l.beginPath(), l.moveTo(M[0].x, M[0].y), st(l, Y), P)
752
- for (let E = g.length - 1; E >= 0; E--)
753
- l.lineTo(g[E][0], g[E][1]);
791
+ if (l.beginPath(), l.moveTo(w[0].x, w[0].y), et(l, F), P)
792
+ for (let k = d.length - 1; k >= 0; k--)
793
+ l.lineTo(d[k][0], d[k][1]);
754
794
  else {
755
- const E = ot(g), ct = tt(E, p, y === "grow" && C.length > 0), Z = E[E.length - 1];
756
- l.lineTo(Z.x, Z.y), yt(l, E, ct);
795
+ const k = st(d), ct = tt(k, c, g === "grow" && I.length > 0), Z = k[k.length - 1];
796
+ l.lineTo(Z.x, Z.y), gt(l, k, ct);
757
797
  }
758
- l.closePath(), l.fillStyle = H, l.fill();
798
+ l.closePath(), l.fillStyle = O, l.fill();
759
799
  }
760
- const Q = r && d < 1;
761
- if (Q && (l.save(), l.globalAlpha *= d), r && (l.beginPath(), l.moveTo(M[0].x, M[0].y), st(l, Y), l.strokeStyle = A, l.lineWidth = m, l.lineJoin = "round", l.lineCap = "round", l.stroke()), Q && l.restore(), this.options.points?.visible) {
762
- const R = d < 1;
763
- R && (l.save(), l.globalAlpha *= d), this.drawPointMarkers({ context: l, points: M, pixelRatio: i.horizontalPixelRatio, color: A }), R && l.restore();
800
+ const Q = h && v < 1;
801
+ if (Q && (l.save(), l.globalAlpha *= v), h && (l.beginPath(), l.moveTo(w[0].x, w[0].y), et(l, F), l.strokeStyle = b, l.lineWidth = m, l.lineJoin = "round", l.lineCap = "round", l.stroke()), Q && l.restore(), this.options.points?.visible) {
802
+ const R = v < 1;
803
+ R && (l.save(), l.globalAlpha *= v), this.drawPointMarkers({ context: l, points: w, pixelRatio: e.horizontalPixelRatio, color: b }), R && l.restore();
764
804
  }
765
805
  K && l.restore();
766
806
  }
767
- this.stackedEdges = { times: c, cumulative: z, growChain: C, collapse: _ };
807
+ this.stackedEdges = { times: a, cumulative: D, growChain: I, collapse: U };
768
808
  }
769
809
  /**
770
810
  * Overlay hook: draws crosshair nearest-point dots and last-point pulse dots.
@@ -772,81 +812,82 @@ class bt extends ut {
772
812
  */
773
813
  drawOverlay(t) {
774
814
  this.tickAnimations(performance.now());
775
- const { scope: e, timeScale: i, yScale: o, crosshair: s, dataInterval: l } = t, a = e, f = this.options.pulseMs, r = f > 0 ? performance.now() / (f * 2 * Math.PI) % 1 : 0;
815
+ const { scope: i, timeScale: e, yScale: o, crosshair: s, dataInterval: l } = t, r = i, f = this.options.pulseMs, h = f > 0 ? performance.now() / (f * 2 * Math.PI) % 1 : 0;
776
816
  if (s) {
777
- const v = this.options.stacking, n = 4 * a.horizontalPixelRatio;
778
- for (let u = 0; u < this.stores.length; u++) {
779
- const c = this.getLayerAlpha(u);
780
- if (c <= 0) continue;
781
- const y = this.stores[u].findNearest(s.time, l);
782
- if (!y || v === "off" && !o.isPlottable(y.value)) continue;
783
- const k = this.resolveLayerColor(u, y.value), { x: w, y: B } = v === "off" ? {
784
- x: i.timeToBitmapXExact(y.time),
785
- y: o.valueToBitmapYExact(this.effectiveValue(t, u, y.time, y.value))
786
- } : this.stackedPositionAt(t, u, y.time), L = c < 1;
787
- L && (e.context.save(), e.context.globalAlpha *= c), e.context.save(), e.context.globalAlpha *= 0.25, e.context.beginPath(), e.context.arc(w, B, n + 3 * a.horizontalPixelRatio, 0, Math.PI * 2), e.context.fillStyle = k, e.context.fill(), e.context.restore(), e.context.beginPath(), e.context.arc(w, B, n, 0, Math.PI * 2), e.context.fillStyle = k, e.context.fill(), L && e.context.restore();
817
+ const x = this.options.stacking, n = 4 * r.horizontalPixelRatio;
818
+ for (let p = 0; p < this.stores.length; p++) {
819
+ const a = this.getLayerAlpha(p);
820
+ if (a <= 0) continue;
821
+ const g = this.stores[p].findNearest(s.time, l);
822
+ if (!g || x === "off" && !o.isPlottable(g.value)) continue;
823
+ const A = this.resolveLayerColor(p, g.value), { x: E, y: B } = x === "off" ? {
824
+ x: e.timeToBitmapXExact(g.time),
825
+ y: o.valueToBitmapYExact(this.effectiveValue(t, p, g.time, g.value))
826
+ } : this.stackedPositionAt(t, p, g.time), L = a < 1;
827
+ L && (i.context.save(), i.context.globalAlpha *= a), i.context.save(), i.context.globalAlpha *= 0.25, i.context.beginPath(), i.context.arc(E, B, n + 3 * r.horizontalPixelRatio, 0, Math.PI * 2), i.context.fillStyle = A, i.context.fill(), i.context.restore(), i.context.beginPath(), i.context.arc(E, B, n, 0, Math.PI * 2), i.context.fillStyle = A, i.context.fill(), L && i.context.restore();
788
828
  }
789
829
  }
790
830
  const m = this.introWave.active && this.introDirectives?.clip !== void 0;
791
- let p = 1;
792
- if (m && (p = Math.max(0, (this.introWave.linear() - (1 - J)) / J)), this.hasPulse && f > 0 && p > 0) {
793
- const v = this.options.stacking;
831
+ let c = 1;
832
+ if (m && (c = Math.max(0, (this.introWave.linear() - (1 - J)) / J)), this.hasPulse && f > 0 && c > 0) {
833
+ const x = this.options.stacking;
794
834
  for (let n = 0; n < this.stores.length; n++) {
795
- const u = this.getLayerAlpha(n);
796
- if (u <= 0) continue;
797
- const c = this.stores[n].last()?.value ?? 0, y = this.resolveLayerColor(n, c);
798
- if (v === "off") {
799
- if (!o.isPlottable(c)) continue;
835
+ const p = this.getLayerAlpha(n);
836
+ if (p <= 0) continue;
837
+ const a = this.stores[n].last()?.value ?? 0, g = this.resolveLayerColor(n, a);
838
+ if (x === "off") {
839
+ if (!o.isPlottable(a)) continue;
800
840
  const L = this.trailingEndpoint(t, n);
801
841
  if (!L) continue;
802
842
  this.drawPulse({
803
- ctx: e.context,
843
+ ctx: i.context,
804
844
  x: L.x,
805
845
  y: L.y,
806
- color: y,
807
- pixelRatio: a.horizontalPixelRatio,
808
- phase: r,
809
- alpha: u * p
846
+ color: g,
847
+ pixelRatio: r.horizontalPixelRatio,
848
+ phase: h,
849
+ alpha: p * c
810
850
  });
811
851
  continue;
812
852
  }
813
- const k = this.stores[n].last();
814
- if (!k) continue;
815
- const { x: w, y: B } = this.stackedPositionAt(t, n, k.time);
853
+ const A = this.stores[n].last();
854
+ if (!A) continue;
855
+ const { x: E, y: B } = this.stackedPositionAt(t, n, A.time);
816
856
  this.drawPulse({
817
- ctx: e.context,
818
- x: w,
857
+ ctx: i.context,
858
+ x: E,
819
859
  y: B,
820
- color: y,
821
- pixelRatio: a.horizontalPixelRatio,
822
- phase: r,
823
- alpha: u * p
860
+ color: g,
861
+ pixelRatio: r.horizontalPixelRatio,
862
+ phase: h,
863
+ alpha: p * c
824
864
  });
825
865
  }
826
866
  }
827
867
  }
828
868
  drawPulse({
829
869
  ctx: t,
830
- x: e,
831
- y: i,
870
+ x: i,
871
+ y: e,
832
872
  color: o,
833
873
  pixelRatio: s,
834
874
  phase: l,
835
- alpha: a = 1
875
+ alpha: r = 1
836
876
  }) {
837
- const f = 3 * s, r = 0.4 + 0.6 * Math.abs(Math.sin(l * 2 * Math.PI)), m = f + 4 * s * r, p = a < 1;
838
- p && (t.save(), t.globalAlpha *= a), t.beginPath(), t.arc(e, i, m, 0, Math.PI * 2), t.fillStyle = X(o, r * 0.3), t.fill(), t.beginPath(), t.arc(e, i, f, 0, Math.PI * 2), t.fillStyle = o, t.fill(), p && t.restore();
877
+ const f = 3 * s, h = 0.4 + 0.6 * Math.abs(Math.sin(l * 2 * Math.PI)), m = f + 4 * s * h, c = r < 1;
878
+ c && (t.save(), t.globalAlpha *= r), t.beginPath(), t.arc(i, e, m, 0, Math.PI * 2), t.fillStyle = X(o, h * 0.3), t.fill(), t.beginPath(), t.arc(i, e, f, 0, Math.PI * 2), t.fillStyle = o, t.fill(), c && t.restore();
839
879
  }
840
880
  }
841
881
  const Bt = {
842
882
  type: "line",
843
- create: ({ theme: x, layerCount: t }, e) => new bt(t, {
844
- colors: t === 1 ? [x.line.color] : x.seriesColors.slice(0, t),
845
- strokeWidth: x.line.width,
846
- ...e
883
+ xTypes: ["time", "numeric", "category"],
884
+ create: ({ theme: y, layerCount: t }, i) => new Pt(t, {
885
+ colors: t === 1 ? [y.line.color] : y.seriesColors.slice(0, t),
886
+ strokeWidth: y.line.width,
887
+ ...i
847
888
  })
848
889
  };
849
890
  export {
850
- bt as LineRenderer,
891
+ Pt as LineRenderer,
851
892
  Bt as LineSeriesDef
852
893
  };