@wick-charts/vue 0.8.0 → 0.8.1

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.
@@ -1,10 +1,10 @@
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 $ } from "../animation/easing.js";
2
+ import { easeOutCubic as U } from "../animation/easing.js";
3
3
  import { decimateLineData as q } from "../data/decimation.js";
4
- import { hexToRgba as X } from "../utils/color.js";
5
- import { lerp as N } from "../utils/math.js";
4
+ import { hexToRgba as C } from "../utils/color.js";
5
+ import { lerp as z } from "../utils/math.js";
6
6
  import { BaseMultiLayerSeries as ut } from "./base-multi-layer.js";
7
- import { unfoldIntro as ft, scaleMean as mt, backfillSweepIntro as pt } from "./line-intro.js";
7
+ import { unfoldIntro as mt, scaleMean as pt, backfillSweepIntro as ft } from "./line-intro.js";
8
8
  import { buildCurveSegments as tt, replaySegmentsForward as et, replaySegmentsReversed as gt } from "./painters/canvas-path.js";
9
9
  import { resolveLinePainter as dt } from "./painters/resolve.js";
10
10
  import { ScaleStack as it } from "./scale-stack.js";
@@ -36,22 +36,24 @@ function ot(y) {
36
36
  function st(y) {
37
37
  return y.map(([t, i]) => ({ x: t, y: i }));
38
38
  }
39
- const J = 0.15, xt = pt();
39
+ const J = 0.15, xt = ft();
40
40
  function j(y, t, i) {
41
- const { resolve: e, lerp: o = N } = i;
41
+ const { resolve: e, lerp: o = z } = i;
42
42
  if (y.length === 0) return null;
43
43
  if (t <= y[0].time) return Number.isFinite(y[0].value) ? e(y[0]) : null;
44
44
  const s = y[y.length - 1];
45
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);
46
+ let a = 0, r = y.length - 1;
47
+ for (; r - a > 1; ) {
48
+ const c = a + r >> 1;
49
+ y[c].time <= t ? a = c : r = c;
50
+ }
51
+ const m = y[a];
52
+ if (m.time === t) return Number.isFinite(m.value) ? e(m) : null;
53
+ const h = y[r];
54
+ if (!Number.isFinite(m.value) || !Number.isFinite(h.value)) return null;
55
+ const p = h.time - m.time;
56
+ return p <= 0 ? e(m) : o(e(m), e(h), (t - m.time) / p);
55
57
  }
56
58
  function yt(y, t) {
57
59
  let i = 0, e = y.length - 1;
@@ -106,8 +108,8 @@ class Pt extends ut {
106
108
  }
107
109
  const o = this.historyDirectives, s = o?.ghostAlpha ?? 0;
108
110
  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());
111
+ const a = this.applyHistoryClip(t, o, e);
112
+ this.introWave.active ? this.renderWithIntro(t) : (this.introDirectives = null, this.renderBody(t)), a && i.restore(), o?.heads !== void 0 && o.heads.length > 0 && this.drawIntroHeads(t, o.heads, this.historyWave.linear());
111
113
  }
112
114
  /**
113
115
  * Initial-load intro pass: the resolved LineIntroFn describes this frame
@@ -117,14 +119,14 @@ class Pt extends ut {
117
119
  renderWithIntro(t) {
118
120
  const i = this.resolveIntro()(this.buildIntroFrame(t));
119
121
  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);
123
- if (f) {
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();
122
+ const { context: e } = t.scope, { width: o, height: s } = t.scope.bitmapSize, a = i.ghostAlpha ?? 0;
123
+ a > 0 && (e.save(), e.globalAlpha *= a, this.introGhostPass = !0, this.renderBody(t), this.introGhostPass = !1, e.restore());
124
+ const r = i.clip, m = r !== void 0 && (r.fromX !== void 0 || r.toX !== void 0);
125
+ if (m) {
126
+ const h = r.fromX ?? 0, p = r.toX ?? o;
127
+ e.save(), e.beginPath(), e.rect(h, 0, Math.max(0, p - h), s), e.clip();
126
128
  }
127
- this.renderBody(t), f && e.restore(), i.heads !== void 0 && i.heads.length > 0 && this.drawIntroHeads(t, i.heads, this.introWave.linear());
129
+ this.renderBody(t), m && e.restore(), i.heads !== void 0 && i.heads.length > 0 && this.drawIntroHeads(t, i.heads, this.introWave.linear());
128
130
  }
129
131
  /**
130
132
  * Apply the history reveal's clip directive, mapped from reveal space
@@ -135,8 +137,8 @@ class Pt extends ut {
135
137
  applyHistoryClip(t, i, e) {
136
138
  const o = i?.clip;
137
139
  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;
140
+ const { context: s } = t.scope, { width: a, height: r } = t.scope.bitmapSize, m = t.timeScale.timeToBitmapXExact(e.to), h = Math.abs(m - t.timeScale.timeToBitmapXExact(e.from)), p = Math.max(2, (this.options.strokeWidth ?? 1) * t.scope.horizontalPixelRatio), c = o.fromX ?? 0, x = o.toX ?? h;
141
+ return s.save(), s.beginPath(), s.rect(m - x - p, 0, Math.max(0, x - c + p), r), s.rect(m, 0, Math.max(0, a - m), r), s.clip(), !0;
140
142
  }
141
143
  renderBody(t) {
142
144
  this.options.stacking === "off" ? (this.stackedEdges = null, this.renderOff(t)) : this.renderStacked(t, this.options.stacking === "percent");
@@ -166,7 +168,7 @@ class Pt extends ut {
166
168
  defaultIntro = null;
167
169
  resolveIntro() {
168
170
  const t = this.options.introAnimation;
169
- return t !== void 0 ? t : (this.defaultIntro === null && (this.defaultIntro = ft()), this.defaultIntro);
171
+ return t !== void 0 ? t : (this.defaultIntro === null && (this.defaultIntro = mt()), this.defaultIntro);
170
172
  }
171
173
  /**
172
174
  * Frame context handed to the intro fn — progress plus memoized data
@@ -198,39 +200,39 @@ class Pt extends ut {
198
200
  });
199
201
  }
200
202
  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);
203
+ const { timeScale: e, yScale: o, scope: s } = t, { progress: a, range: r, width: m } = i, h = this.options.stacking === "percent", p = new Array(this.stores.length), c = new Array(this.stores.length);
202
204
  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;
205
+ const f = (l) => {
206
+ let g = p[l];
207
+ return g === void 0 && (g = this.stores[l]?.getVisibleData(r.from, r.to) ?? [], p[l] = g), g;
206
208
  };
207
209
  return {
208
- progress: l,
210
+ progress: a,
209
211
  range: r,
210
- width: f,
212
+ width: m,
211
213
  height: o.getMediaHeight() * s.verticalPixelRatio,
212
214
  stacking: this.options.stacking,
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),
215
+ timeToX: (l) => e.timeToBitmapXExact(l),
216
+ xToTime: (l) => e.xToTime(l / s.horizontalPixelRatio),
217
+ valueToY: (l) => o.valueToBitmapYExact(l),
218
+ lerpValue: (l, g, b) => o.lerpValue(l, g, b),
217
219
  layerCount: this.stores.length,
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;
220
+ layerData: f,
221
+ layerMean: (l) => {
222
+ let g = c[l];
223
+ return g === void 0 && (h ? (x ??= this.meanShares(f, o), g = x[l]) : g = pt(f(l), o), c[l] = g), g;
222
224
  },
223
225
  primaryPath: () => {
224
226
  if (n === void 0) {
225
227
  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));
228
+ for (let l = 0; l < this.stores.length; l++) {
229
+ if (this.getLayerAlpha(l) <= 0 || !this.stores[l].isVisible()) continue;
230
+ const g = f(l).filter((b) => o.isPlottable(b.value));
229
231
  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
232
+ n = g.map((b) => ({
233
+ x: e.timeToBitmapXExact(b.time),
234
+ y: o.valueToBitmapYExact(b.value),
235
+ time: b.time
234
236
  }));
235
237
  break;
236
238
  }
@@ -252,9 +254,9 @@ class Pt extends ut {
252
254
  }
253
255
  /** Layer's share of its column in percent, passed through the intro value transform. */
254
256
  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;
257
+ const { layerIndex: e, time: o, value: s, total: a } = i;
258
+ if (a <= 0) return s;
259
+ const r = s / a * 100;
258
260
  return Math.max(0, this.introValue(t, { layerIndex: e, time: o, value: r }));
259
261
  }
260
262
  /**
@@ -265,40 +267,40 @@ class Pt extends ut {
265
267
  meanShares(t, i) {
266
268
  const e = this.stores.length, o = /* @__PURE__ */ new Set();
267
269
  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;
270
+ for (const p of t(h))
271
+ o.add(p.time);
272
+ const s = new Array(e).fill(0), a = new Array(e).fill(!1), r = new Array(e);
273
+ let m = 0;
272
274
  for (const h of o) {
273
- let m = 0;
275
+ let p = 0;
274
276
  for (let c = 0; c < e; c++) {
275
277
  r[c] = null;
276
278
  const x = this.getLayerAlpha(c), n = t(c);
277
279
  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
+ const f = j(n, h, { resolve: (l) => l.value });
281
+ f === null || !i.isPlottable(f) || (r[c] = f * x, p += f * x);
280
282
  }
281
- if (!(m <= 0)) {
282
- f++;
283
+ if (!(p <= 0)) {
284
+ m++;
283
285
  for (let c = 0; c < e; c++) {
284
286
  const x = r[c];
285
- x !== null && (s[c] += x / m * 100, l[c] = !0);
287
+ x !== null && (s[c] += x / p * 100, a[c] = !0);
286
288
  }
287
289
  }
288
290
  }
289
- return s.map((h, m) => l[m] ? h / f : null);
291
+ return s.map((h, p) => a[p] ? h / m : null);
290
292
  }
291
293
  /** The active history-reveal or intro value transform applied to one value. */
292
294
  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 { layerIndex: e, time: o, value: s } = i, a = this.historyWave.active ? this.historyDirectives?.value : void 0, r = this.historyRange;
296
+ if (a !== void 0 && r !== null && o < r.to) {
295
297
  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 });
298
+ return a({ layerIndex: e, time: o, value: s, position: n });
297
299
  }
298
- const f = this.introWave.active ? this.introDirectives?.value : void 0;
299
- if (f === void 0) return s;
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 });
300
+ const m = this.introWave.active ? this.introDirectives?.value : void 0;
301
+ if (m === void 0) return s;
302
+ const h = t.timeScale.getRange(), p = h.to - h.from, c = p > 0 ? Math.min(1, Math.max(0, (o - h.from) / p)) : 0;
303
+ return m({ layerIndex: e, time: o, value: s, position: c });
302
304
  }
303
305
  /**
304
306
  * Extends the base last-value query with the 'grow' entrance's value-space
@@ -322,22 +324,22 @@ class Pt extends ut {
322
324
  if (e.length === 0) return null;
323
325
  const o = this.stores[t].getAll(), s = o.length - 1 - e.length;
324
326
  if (s < 0) return null;
325
- const l = o[s];
326
- if (!Number.isFinite(l.value)) return null;
327
- let r = i(l.time, l.value);
328
- const f = /* @__PURE__ */ new Map();
327
+ const a = o[s];
328
+ if (!Number.isFinite(a.value)) return null;
329
+ let r = i(a.time, a.value);
330
+ const m = /* @__PURE__ */ new Map();
329
331
  for (let h = 0; h < e.length; h++) {
330
- const m = o[s + 1 + h];
331
- if (!Number.isFinite(m.value)) return null;
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;
332
+ const p = o[s + 1 + h];
333
+ if (!Number.isFinite(p.value)) return null;
334
+ const c = U(e[h].progress), x = i(p.time, p.value), n = this.axisLerp(r, x, c);
335
+ m.set(p.time, n), r = n;
334
336
  }
335
- return f;
337
+ return m;
336
338
  }
337
339
  /** `lerp` along the last rendered Y axis — plain before the first render. */
338
340
  axisLerp(t, i, e) {
339
341
  const o = this.lastYScale;
340
- return o === null ? N(t, i, e) : o.lerpValue(t, i, e);
342
+ return o === null ? z(t, i, e) : o.lerpValue(t, i, e);
341
343
  }
342
344
  /**
343
345
  * Glowing pulse dots riding the intro's head anchors — the line reads as
@@ -347,14 +349,14 @@ class Pt extends ut {
347
349
  */
348
350
  drawIntroHeads(t, i, e) {
349
351
  if (this.options.stacking !== "off") return;
350
- const o = Math.min(1, e / J), s = Math.min(1, (1 - e) / J), l = Math.max(0, Math.min(o, s));
351
- if (l <= 0) return;
352
+ const o = Math.min(1, e / J), s = Math.min(1, (1 - e) / J), a = Math.max(0, Math.min(o, s));
353
+ if (a <= 0) return;
352
354
  const { scope: r } = t;
353
- for (const f of i)
355
+ for (const m of i)
354
356
  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);
357
+ const p = this.getLayerAlpha(h);
358
+ if (p <= 0 || !this.stores[h].isVisible()) continue;
359
+ const c = this.introHeadAnchor(t, h, m);
358
360
  c !== null && this.drawPulse({
359
361
  ctx: r.context,
360
362
  x: c.x,
@@ -362,7 +364,7 @@ class Pt extends ut {
362
364
  color: this.resolveLayerColor(h, c.value),
363
365
  pixelRatio: r.horizontalPixelRatio,
364
366
  phase: e * 2,
365
- alpha: l * m
367
+ alpha: a * p
366
368
  });
367
369
  }
368
370
  }
@@ -378,13 +380,13 @@ class Pt extends ut {
378
380
  * visible range, not the data span) and jumps back on settle.
379
381
  */
380
382
  introHeadAnchor(t, i, e) {
381
- const { timeScale: o, yScale: s } = t, l = o.getRange(), r = this.stores[i].getVisibleData(l.from, l.to);
383
+ const { timeScale: o, yScale: s } = t, a = o.getRange(), r = this.stores[i].getVisibleData(a.from, a.to);
382
384
  if (r.length === 0) return null;
383
- const f = this.stores[i].last();
384
- if (f !== void 0 && e.time >= f.time) {
385
- if (!s.isPlottable(f.value)) return null;
385
+ const m = this.stores[i].last();
386
+ if (m !== void 0 && e.time >= m.time) {
387
+ if (!s.isPlottable(m.value)) return null;
386
388
  const c = this.trailingEndpoint(t, i);
387
- return c === null ? null : { x: c.x, y: c.y, value: f.value };
389
+ return c === null ? null : { x: c.x, y: c.y, value: m.value };
388
390
  }
389
391
  const h = r[0];
390
392
  if (e.time <= h.time) {
@@ -396,12 +398,12 @@ class Pt extends ut {
396
398
  value: h.value
397
399
  };
398
400
  }
399
- const m = j(r, e.time, {
401
+ const p = j(r, e.time, {
400
402
  resolve: (c) => this.effectiveValue(t, i, c.time, c.value),
401
403
  // Along the axis, so the dot stays on the straight segment the stroke draws.
402
404
  lerp: (c, x, n) => !s.isPlottable(c) || !s.isPlottable(x) ? Number.NaN : s.lerpValue(c, x, n)
403
405
  });
404
- return m === null || !s.isPlottable(m) ? null : { x: e.x, y: s.valueToBitmapYExact(m), value: m };
406
+ return p === null || !s.isPlottable(p) ? null : { x: e.x, y: s.valueToBitmapYExact(p), value: p };
405
407
  }
406
408
  /**
407
409
  * Rendered positions of the layer's still-unsettled trailing points, keyed
@@ -426,49 +428,49 @@ class Pt extends ut {
426
428
  * it (see `renderStacked`'s `valueMaps` comment for the full rationale).
427
429
  */
428
430
  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) => {
431
+ const o = this.options.stacking === "percent", s = (this.options.entryAnimation ?? "grow") === "grow", a = new Array(this.stores.length), r = (n) => {
430
432
  if (!s) return null;
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;
435
- }, f = (n) => {
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)
433
+ const f = a[n];
434
+ if (f !== void 0) return f;
435
+ const l = this.chainedTailValues(n, (g, b) => this.effectiveValue(t, n, g, b));
436
+ return a[n] = l, l;
437
+ }, m = (n) => {
438
+ const f = this.stores[n].getAll();
439
+ if (f.length === 0 || e < f[0].time) return null;
440
+ const l = r(n);
441
+ return j(f, e, {
442
+ resolve: (g) => l?.get(g.time) ?? this.effectiveValue(t, n, g.time, g.value)
441
443
  });
442
444
  }, { yScale: h } = t;
443
445
  if (h.getTransform() !== null && !o) {
444
446
  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);
447
+ for (let f = 0; f <= i; f++) {
448
+ const l = this.getLayerAlpha(f), g = l > 0 ? m(f) : null;
449
+ g !== null && h.isPlottable(g) && n.push(g, l);
448
450
  }
449
451
  return n.edge;
450
452
  }
451
- const m = (n) => {
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;
453
+ const p = (n) => {
454
+ const f = this.getLayerAlpha(n);
455
+ if (f <= 0) return null;
456
+ const l = this.stores[n].getAll();
457
+ if (o && l.length > 0 && e < l[0].time) return 0;
458
+ const g = m(n);
459
+ return g === null ? null : g * f;
458
460
  };
459
461
  let c = 0;
460
462
  if (o)
461
463
  for (let n = 0; n < this.stores.length; n++)
462
- c += m(n) ?? 0;
464
+ c += p(n) ?? 0;
463
465
  let x = 0;
464
466
  for (let n = 0; n <= i; n++) {
465
- const p = m(n);
466
- if (p !== null)
467
+ const f = p(n);
468
+ if (f !== null)
467
469
  if (o) {
468
- const a = this.introShare(t, { layerIndex: n, time: e, value: p, total: c });
469
- x = Math.min(100, x + a);
470
+ const l = this.introShare(t, { layerIndex: n, time: e, value: f, total: c });
471
+ x = Math.min(100, x + l);
470
472
  } else
471
- x += p;
473
+ x += f;
472
474
  }
473
475
  return x;
474
476
  }
@@ -486,11 +488,11 @@ class Pt extends ut {
486
488
  stackedPositionAt(t, i, e) {
487
489
  const o = this.paintedStackVertex(t, i, e);
488
490
  if (o !== null) return o;
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);
491
+ const { timeScale: s, yScale: a } = t, r = a.valueToBitmapYExact(this.stackedValueAt(t, i, e)), m = s.timeToBitmapXExact(e), h = this.unsettledTail(i), p = this.stores[i].getAll(), c = p.length - 1 - h.length;
492
+ if ((this.options.entryAnimation ?? "grow") !== "grow" || e !== p[p.length - 1]?.time || h.length === 0 || c < 0) return { x: m, y: r };
493
+ let x = s.timeToBitmapXExact(p[c].time);
492
494
  for (let n = 0; n < h.length; n++)
493
- x = N(x, s.timeToBitmapXExact(m[c + 1 + n].time), $(h[n].progress));
495
+ x = z(x, s.timeToBitmapXExact(p[c + 1 + n].time), U(h[n].progress));
494
496
  return { x, y: r };
495
497
  }
496
498
  /** Upper-edge vertex of layer `li` at column `t`, replayed from the last
@@ -498,29 +500,29 @@ class Pt extends ut {
498
500
  paintedStackVertex(t, i, e) {
499
501
  const o = this.stackedEdges, s = o?.cumulative[i];
500
502
  if (o === null || s === void 0) return null;
501
- const { times: l, growChain: r, collapse: f } = o, h = yt(l, e);
503
+ const { times: a, growChain: r, collapse: m } = o, h = yt(a, e);
502
504
  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]);
505
+ const { timeScale: p, yScale: c } = t, x = t.scope.bitmapSize.height, n = m[i] ?? 1, f = c.valueToBitmapYExact(s[h]), l = n >= 1 ? f : x + (f - x) * n, g = a.length - r.length;
506
+ if (h < g) return { x: p.timeToBitmapXExact(e), y: l };
507
+ let b = p.timeToBitmapXExact(a[g - 1]);
506
508
  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
+ b = z(b, p.timeToBitmapXExact(a[g + E]), r[E]);
510
+ return { x: b, y: l };
509
511
  }
510
512
  chainedTailPositions(t, i) {
511
513
  const e = this.unsettledTail(i);
512
514
  if (e.length === 0) return null;
513
515
  const o = this.stores[i].getAll(), s = o.length - 1 - e.length;
514
516
  if (s < 0) return null;
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));
517
+ const { timeScale: a, yScale: r } = t, m = o[s];
518
+ if (!r.isPlottable(m.value)) return null;
519
+ let h = a.timeToBitmapXExact(m.time), p = r.valueToBitmapYExact(this.effectiveValue(t, i, m.time, m.value));
518
520
  const c = /* @__PURE__ */ new Map();
519
521
  for (let x = 0; x < e.length; x++) {
520
522
  const n = o[s + 1 + x];
521
523
  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;
524
+ const f = U(e[x].progress), l = a.timeToBitmapXExact(n.time), g = r.valueToBitmapYExact(this.effectiveValue(t, i, n.time, n.value)), b = z(h, l, f), E = z(p, g, f);
525
+ c.set(n.time, { x: b, y: E }), h = b, p = E;
524
526
  }
525
527
  return c;
526
528
  }
@@ -537,8 +539,8 @@ class Pt extends ut {
537
539
  trailingEndpoint(t, i) {
538
540
  const e = this.stores[i].last();
539
541
  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 };
542
+ const { timeScale: o, yScale: s } = t, a = o.timeToBitmapXExact(e.time), r = s.valueToBitmapYExact(this.effectiveValue(t, i, e.time, e.value));
543
+ return (this.options.entryAnimation ?? "grow") !== "grow" ? { x: a, y: r } : this.chainedTailPositions(t, i)?.get(e.time) ?? { x: a, y: r };
542
544
  }
543
545
  /**
544
546
  * Vertical stroke + area gradients for `options.threshold`, pinned to the
@@ -552,10 +554,10 @@ class Pt extends ut {
552
554
  buildThresholdPaint(t, i) {
553
555
  const e = this.options.threshold;
554
556
  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 };
557
+ const { scope: o, yScale: s } = t, { context: a } = o, r = o.bitmapSize.height, m = e.above, h = e.below ?? i, p = 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, p - c), n = Math.min(1, p + c), f = a.createLinearGradient(0, 0, 0, r);
558
+ f.addColorStop(0, m), f.addColorStop(x, m), f.addColorStop(n, h), f.addColorStop(1, h);
559
+ const l = a.createLinearGradient(0, 0, 0, r);
560
+ return l.addColorStop(0, C(m, 0.26)), l.addColorStop(x, C(m, 0.14)), l.addColorStop(n, C(h, 0.1)), l.addColorStop(1, C(h, 0.01)), { stroke: f, area: l };
559
561
  }
560
562
  /**
561
563
  * Dot markers at each data point (`options.points`). Callers pass the same
@@ -568,61 +570,61 @@ class Pt extends ut {
568
570
  drawPointMarkers(t) {
569
571
  const i = this.options.points;
570
572
  if (!i?.visible) return;
571
- const { context: e, points: o, pixelRatio: s, color: l } = t;
573
+ const { context: e, points: o, pixelRatio: s, color: a } = t;
572
574
  if (o.length === 0) return;
573
575
  const r = Math.max(1, (i.radius ?? 3) * s);
574
576
  if (!(o.length > 1 && (o[o.length - 1].x - o[0].x) / (o.length - 1) < r * 3)) {
575
577
  e.beginPath();
576
- for (const f of o)
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();
578
+ for (const m of o)
579
+ e.moveTo(m.x + r, m.y), e.arc(m.x, m.y, r, 0, Math.PI * 2);
580
+ e.fillStyle = i.color ?? a, e.fill();
579
581
  }
580
582
  }
581
583
  /** Each layer drawn independently */
582
584
  renderOff(t) {
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 = {
585
+ const { scope: i, timeScale: e, yScale: o } = t, { context: s } = i, a = e.getRange(), { verticalPixelRatio: r } = i, m = this.options.strokeWidth > 0, h = Math.max(1, Math.round(this.options.strokeWidth * r)), p = this.options.entryAnimation ?? "grow", c = dt(this.options.linePainter ?? this.options.curve ?? "straight"), x = {
584
586
  ctx: s,
585
587
  theme: t.theme,
586
588
  horizontalPixelRatio: i.horizontalPixelRatio,
587
589
  verticalPixelRatio: r
588
590
  };
589
591
  for (let n = 0; n < this.stores.length; n++) {
590
- const p = this.getLayerAlpha(n);
591
- if (p <= 0) continue;
592
- let a = this.stores[n].getVisibleData(l.from, l.to);
592
+ const f = this.getLayerAlpha(n);
593
+ if (f <= 0) continue;
594
+ let l = this.stores[n].getVisibleData(a.from, a.to);
593
595
  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),
597
- y: o.valueToBitmapYExact(this.effectiveValue(t, n, L.time, L.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 = [];
596
+ if (l.length > g * 2 && (l = q(l, Math.round(g * 1.5))), l.length < 2) continue;
597
+ const b = this.lastFinitePoint(n)?.value ?? l[l.length - 1].value, E = this.resolveLayerColor(n, b), B = this.buildThresholdPaint(t, E), V = l[l.length - 1], Y = this.stores[n].last(), D = Y !== void 0 && V.time === Y.time, N = D ? this.entranceProgress(n, V.time) : 1, I = D && p === "fade" && N < 1, H = (D ? this.trailingEndpoint(t, n) : null) ?? {
598
+ x: e.timeToBitmapXExact(V.time),
599
+ y: o.valueToBitmapYExact(this.effectiveValue(t, n, V.time, V.value))
600
+ }, F = H.x, X = H.y, $ = D && p === "grow" ? this.chainedTailPositions(t, n) : null, G = f < 1;
601
+ (G || I) && (s.save(), G && (s.globalAlpha *= f), I && (s.globalAlpha *= N));
602
+ const _ = l.length - 1, u = [];
601
603
  let v = null;
602
- for (let d = 0; d < U; d++) {
603
- const S = a[d].value;
604
+ for (let d = 0; d < _; d++) {
605
+ const S = l[d].value;
604
606
  if (!o.isPlottable(S)) {
605
607
  v = null;
606
608
  continue;
607
609
  }
608
610
  v || (v = [], u.push(v));
609
- const w = _?.get(a[d].time);
611
+ const w = $?.get(l[d].time);
610
612
  if (w)
611
613
  v.push({ x: w.x, y: w.y });
612
614
  else {
613
- const F = o.valueToBitmapYExact(this.effectiveValue(t, n, a[d].time, S));
614
- v.push({ x: e.timeToBitmapXExact(a[d].time), y: F });
615
+ const W = o.valueToBitmapYExact(this.effectiveValue(t, n, l[d].time, S));
616
+ v.push({ x: e.timeToBitmapXExact(l[d].time), y: W });
615
617
  }
616
618
  }
617
- const M = a[U]?.value, b = Number.isFinite(W) && Number.isFinite(C) && o.isPlottable(M), P = m === "grow" && z < 1;
618
- let T = null;
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)) {
619
+ const T = l[_]?.value, A = Number.isFinite(F) && Number.isFinite(X) && o.isPlottable(T), P = p === "grow" && N < 1;
620
+ let M = null;
621
+ if (A && (v ? (v.push({ x: F, y: X }), M = v) : u.push([{ x: F, y: X }])), m && u.some((d) => d.length >= 2)) {
620
622
  s.beginPath();
621
623
  for (const d of u)
622
- d.length < 2 || c(x, { points: d, color: E, lineWidth: h, closing: !1, grew: P && d === T });
624
+ d.length < 2 || c(x, { points: d, color: E, lineWidth: h, closing: !1, grew: P && d === M });
623
625
  s.strokeStyle = B ? B.stroke : E, s.lineWidth = h, s.lineJoin = "round", s.lineCap = "round", s.stroke();
624
626
  }
625
- if (f) {
627
+ if (m) {
626
628
  const d = Math.max(1, h / 2);
627
629
  let S = !1;
628
630
  for (const w of u)
@@ -635,12 +637,12 @@ class Pt extends ut {
635
637
  if (B)
636
638
  S = B.area;
637
639
  else {
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 }));
640
+ const w = String(n), W = this.areaGradientCache.get(w);
641
+ W && W.bottomY === d && W.color === E ? S = W.gradient : (S = s.createLinearGradient(0, 0, 0, d), S.addColorStop(0, C(E, 0.12)), S.addColorStop(1, C(E, 0.01)), this.areaGradientCache.set(w, { gradient: S, bottomY: d, color: E }));
640
642
  }
641
643
  s.fillStyle = S;
642
644
  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());
645
+ w.length < 2 || (s.beginPath(), c(x, { points: w, color: E, lineWidth: h, closing: !0, grew: P && w === M }), s.lineTo(w[w.length - 1].x, d), s.lineTo(w[0].x, d), s.closePath(), s.fill());
644
646
  }
645
647
  if (this.options.points?.visible) {
646
648
  const d = [];
@@ -653,158 +655,158 @@ class Pt extends ut {
653
655
  }
654
656
  /** Stacked area rendering */
655
657
  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) => {
658
+ const { scope: e, timeScale: o, yScale: s } = t, { context: a } = e, r = o.getRange(), { verticalPixelRatio: m } = e, h = this.options.strokeWidth > 0, p = Math.max(1, Math.round(this.options.strokeWidth * m)), c = this.options.curve ?? "straight", x = e.mediaSize.width, n = this.stores.map((u, v) => {
657
659
  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();
660
+ let T = u.getVisibleData(r.from, r.to);
661
+ return T.length > x * 2 && (T = q(T, Math.round(x * 1.5))), T;
662
+ }), f = /* @__PURE__ */ new Set();
661
663
  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) {
664
+ for (const v of u) f.add(v.time);
665
+ const l = Array.from(f).sort((u, v) => u - v);
666
+ if (l.length < 2) {
665
667
  this.stackedEdges = null;
666
668
  return;
667
669
  }
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);
670
+ const g = this.options.entryAnimation ?? "grow", b = n.map((u, v) => {
671
+ const T = /* @__PURE__ */ new Map();
672
+ if (u.length === 0) return T;
673
+ const A = u[0].time, P = g === "grow" ? this.chainedTailValues(v, (d, S) => this.effectiveValue(t, v, d, S)) : null, M = (d) => P?.get(d.time) ?? this.effectiveValue(t, v, d.time, d.value);
674
+ for (const d of l) {
675
+ if (d < A) continue;
676
+ const S = j(u, d, { resolve: M });
677
+ S !== null && T.set(d, S);
676
678
  }
677
- return M;
679
+ return T;
678
680
  }), 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];
684
- if (L) {
681
+ const T = b[u].get(v);
682
+ return T === void 0 ? void 0 : T * E[u];
683
+ }, V = s.getTransform() !== null && !i, Y = Array.from({ length: this.stores.length }, () => new Array(l.length).fill(0));
684
+ for (let u = 0; u < l.length; u++) {
685
+ const v = l[u];
686
+ if (V) {
685
687
  const P = new it(s);
686
- for (let T = 0; T < this.stores.length; T++) {
687
- const d = A[T].get(v);
688
- d !== void 0 && s.isPlottable(d) && P.push(d, E[T]), D[T][u] = P.edge;
688
+ for (let M = 0; M < this.stores.length; M++) {
689
+ const d = b[M].get(v);
690
+ d !== void 0 && s.isPlottable(d) && P.push(d, E[M]), Y[M][u] = P.edge;
689
691
  }
690
692
  continue;
691
693
  }
692
- let M = 0;
694
+ let T = 0;
693
695
  if (i)
694
696
  for (let P = 0; P < this.stores.length; P++) {
695
- const T = B(P, v);
696
- T !== void 0 && s.isPlottable(T) && (M += T);
697
+ const M = B(P, v);
698
+ M !== void 0 && s.isPlottable(M) && (T += M);
697
699
  }
698
- let b = 0;
700
+ let A = 0;
699
701
  for (let P = 0; P < this.stores.length; P++) {
700
- const T = B(P, v);
701
- let d = T !== void 0 && s.isPlottable(T) ? T : null;
702
+ const M = B(P, v);
703
+ let d = M !== void 0 && s.isPlottable(M) ? M : null;
702
704
  const S = n[P];
703
705
  if (i && S.length > 0 && v < S[0].time && (d = 0), d !== null)
704
706
  if (i) {
705
- const w = this.introShare(t, { layerIndex: P, time: v, value: d, total: M });
706
- b = Math.min(100, b + w);
707
+ const w = this.introShare(t, { layerIndex: P, time: v, value: d, total: T });
708
+ A = Math.min(100, A + w);
707
709
  } else
708
- b += d;
709
- D[P][u] = b;
710
+ A += d;
711
+ Y[P][u] = A;
710
712
  }
711
713
  }
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);
714
+ const D = /* @__PURE__ */ new Map();
715
+ for (let u = 0; u < l.length; u++) D.set(l[u], u);
716
+ const N = new Array(this.stores.length).fill(1);
715
717
  for (let u = 0; u < this.stores.length; u++) {
716
718
  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;
719
+ const v = this.unsettledTail(u), T = v.length;
720
+ if (T === 0) continue;
721
+ let A = !0;
722
+ for (let P = 0; P < T; P++)
723
+ if (D.get(v[P].time) !== l.length - T + P) {
724
+ A = !1;
723
725
  break;
724
726
  }
725
- b && (z[u] = v[M - 1].progress);
727
+ A && (N[u] = v[T - 1].progress);
726
728
  }
727
729
  const I = [];
728
730
  if (g === "grow") {
729
731
  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;
733
- for (let T = 0; T < n.length; T++) {
734
- if (this.getLayerAlpha(T) <= 0) continue;
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;
732
+ for (let v = l.length - 1; v >= 1; v--) {
733
+ const T = l[v];
734
+ let A = 1, P = !1;
735
+ for (let M = 0; M < n.length; M++) {
736
+ if (this.getLayerAlpha(M) <= 0) continue;
737
+ const d = n[M];
738
+ for (; u[M] >= 0 && d[u[M]].time > T; ) u[M]--;
739
+ if (u[M] < 0 || d[u[M]].time !== T) continue;
740
+ const S = this.entranceProgress(M, T);
741
+ (!P || S > A) && (A = S), P = !0;
740
742
  }
741
- if (!P || b >= 1) break;
742
- I.unshift($(b));
743
+ if (!P || A >= 1) break;
744
+ I.unshift(U(A));
743
745
  }
744
746
  }
745
747
  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]);
748
+ const T = v.length;
749
+ if (!(T === 0 || u.length < T + 1))
750
+ for (let A = 0; A < T; A++) {
751
+ const P = u.length - T + A;
752
+ u[P][0] = z(u[P - 1][0], u[P][0], v[A]);
751
753
  }
752
- }, W = e.bitmapSize.height;
753
- let C = -1, _ = -1;
754
+ }, F = e.bitmapSize.height;
755
+ let X = -1, $ = -1;
754
756
  for (let u = 0; u < this.stores.length; u++)
755
757
  if (!(this.getLayerAlpha(u) <= 0))
756
- if (C < 0)
757
- C = u;
758
+ if (X < 0)
759
+ X = u;
758
760
  else {
759
- _ = u;
761
+ $ = u;
760
762
  break;
761
763
  }
762
- const G = C >= 0 ? this.getLayerAlpha(C) : 1, U = n.map((u, v) => v === C ? Math.min(1, this.getLayerAlpha(v)) : 1);
764
+ const G = X >= 0 ? this.getLayerAlpha(X) : 1, _ = n.map((u, v) => v === X ? Math.min(1, this.getLayerAlpha(v)) : 1);
763
765
  for (let u = this.stores.length - 1; u >= 0; u--) {
764
766
  const v = this.getLayerAlpha(u);
765
767
  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]);
768
+ const T = this.lastFinitePoint(u)?.value ?? 0, A = this.resolveLayerColor(u, T), P = u === X, M = $ >= 0 && u === $ && G < 1, d = [];
769
+ for (let R = 0; R < l.length; R++) {
770
+ const L = u > 0 ? s.valueToBitmapYExact(Y[u - 1][R]) : F;
771
+ let O = L;
772
+ P ? O = F : M && (O = L + (F - L) * (1 - G)), d.push([o.timeToBitmapXExact(l[R]), O]);
771
773
  }
772
774
  g === "grow" && H(d, I);
773
775
  const S = [];
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]);
776
+ for (let R = 0; R < l.length; R++) {
777
+ let L = s.valueToBitmapYExact(Y[u][R]);
778
+ P && v < 1 && (L = F + (L - F) * v), S.push([o.timeToBitmapXExact(l[R]), L]);
777
779
  }
778
780
  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];
781
+ const w = st(S), W = tt(w, c, g === "grow" && I.length > 0), K = g === "fade" && N[u] < 1;
782
+ if (K && (a.save(), a.globalAlpha *= N[u]), this.options.area.visible && !this.introGhostPass) {
783
+ let R = S[0][1], L = d[0][1];
782
784
  for (let k = 1; k < S.length; k++)
783
785
  S[k][1] < R && (R = S[k][1]);
784
786
  for (let k = 1; k < d.length; k++)
785
- d[k][1] > V && (V = d[k][1]);
786
- let O = X(b, 0.25);
787
- if (V > R + 0.5) {
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;
787
+ d[k][1] > L && (L = d[k][1]);
788
+ let O = C(A, 0.25);
789
+ if (L > R + 0.5) {
790
+ const k = a.createLinearGradient(0, R, 0, L);
791
+ k.addColorStop(0, C(A, 0.25)), k.addColorStop(1, C(A, 0.05)), O = k;
790
792
  }
791
- if (l.beginPath(), l.moveTo(w[0].x, w[0].y), et(l, F), P)
793
+ if (a.beginPath(), a.moveTo(w[0].x, w[0].y), et(a, W), P)
792
794
  for (let k = d.length - 1; k >= 0; k--)
793
- l.lineTo(d[k][0], d[k][1]);
795
+ a.lineTo(d[k][0], d[k][1]);
794
796
  else {
795
797
  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);
798
+ a.lineTo(Z.x, Z.y), gt(a, k, ct);
797
799
  }
798
- l.closePath(), l.fillStyle = O, l.fill();
800
+ a.closePath(), a.fillStyle = O, a.fill();
799
801
  }
800
802
  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) {
803
+ if (Q && (a.save(), a.globalAlpha *= v), h && (a.beginPath(), a.moveTo(w[0].x, w[0].y), et(a, W), a.strokeStyle = A, a.lineWidth = p, a.lineJoin = "round", a.lineCap = "round", a.stroke()), Q && a.restore(), this.options.points?.visible) {
802
804
  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();
805
+ R && (a.save(), a.globalAlpha *= v), this.drawPointMarkers({ context: a, points: w, pixelRatio: e.horizontalPixelRatio, color: A }), R && a.restore();
804
806
  }
805
- K && l.restore();
807
+ K && a.restore();
806
808
  }
807
- this.stackedEdges = { times: a, cumulative: D, growChain: I, collapse: U };
809
+ this.stackedEdges = { times: l, cumulative: Y, growChain: I, collapse: _ };
808
810
  }
809
811
  /**
810
812
  * Overlay hook: draws crosshair nearest-point dots and last-point pulse dots.
@@ -812,55 +814,58 @@ class Pt extends ut {
812
814
  */
813
815
  drawOverlay(t) {
814
816
  this.tickAnimations(performance.now());
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;
817
+ const { scope: i, timeScale: e, yScale: o, crosshair: s, dataInterval: a } = t, r = i, m = this.options.pulseMs, h = m > 0 ? performance.now() / (m * 2 * Math.PI) % 1 : 0;
816
818
  if (s) {
817
819
  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);
820
+ for (let f = 0; f < this.stores.length; f++) {
821
+ const l = this.getLayerAlpha(f);
822
+ if (l <= 0) continue;
823
+ const g = this.stores[f].findNearest(s.time, a);
822
824
  if (!g || x === "off" && !o.isPlottable(g.value)) continue;
823
- const A = this.resolveLayerColor(p, g.value), { x: E, y: B } = x === "off" ? {
825
+ const b = this.resolveLayerColor(f, g.value), { x: E, y: B } = x === "off" ? {
824
826
  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();
827
+ y: o.valueToBitmapYExact(this.effectiveValue(t, f, g.time, g.value))
828
+ } : this.stackedPositionAt(t, f, g.time), V = l < 1;
829
+ V && (i.context.save(), i.context.globalAlpha *= l), 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 = b, i.context.fill(), i.context.restore(), i.context.beginPath(), i.context.arc(E, B, n, 0, Math.PI * 2), i.context.fillStyle = b, i.context.fill(), V && i.context.restore();
828
830
  }
829
831
  }
830
- const m = this.introWave.active && this.introDirectives?.clip !== void 0;
832
+ const p = this.introWave.active && this.introDirectives?.clip !== void 0;
831
833
  let c = 1;
832
- if (m && (c = Math.max(0, (this.introWave.linear() - (1 - J)) / J)), this.hasPulse && f > 0 && c > 0) {
834
+ if (p && (c = Math.max(0, (this.introWave.linear() - (1 - J)) / J)), this.hasPulse && m > 0 && c > 0) {
833
835
  const x = this.options.stacking;
834
836
  for (let n = 0; n < this.stores.length; n++) {
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);
837
+ const f = this.getLayerAlpha(n);
838
+ if (f <= 0) continue;
839
+ const l = this.lastFinitePoint(n);
840
+ if (!l) continue;
841
+ const g = this.resolveLayerColor(n, l.value);
838
842
  if (x === "off") {
839
- if (!o.isPlottable(a)) continue;
840
- const L = this.trailingEndpoint(t, n);
841
- if (!L) continue;
843
+ if (!o.isPlottable(l.value)) continue;
844
+ const B = l === this.stores[n].last() ? this.trailingEndpoint(t, n) : {
845
+ x: e.timeToBitmapXExact(l.time),
846
+ y: o.valueToBitmapYExact(this.effectiveValue(t, n, l.time, l.value))
847
+ };
848
+ if (!B) continue;
842
849
  this.drawPulse({
843
850
  ctx: i.context,
844
- x: L.x,
845
- y: L.y,
851
+ x: B.x,
852
+ y: B.y,
846
853
  color: g,
847
854
  pixelRatio: r.horizontalPixelRatio,
848
855
  phase: h,
849
- alpha: p * c
856
+ alpha: f * c
850
857
  });
851
858
  continue;
852
859
  }
853
- const A = this.stores[n].last();
854
- if (!A) continue;
855
- const { x: E, y: B } = this.stackedPositionAt(t, n, A.time);
860
+ const { x: b, y: E } = this.stackedPositionAt(t, n, l.time);
856
861
  this.drawPulse({
857
862
  ctx: i.context,
858
- x: E,
859
- y: B,
863
+ x: b,
864
+ y: E,
860
865
  color: g,
861
866
  pixelRatio: r.horizontalPixelRatio,
862
867
  phase: h,
863
- alpha: p * c
868
+ alpha: f * c
864
869
  });
865
870
  }
866
871
  }
@@ -871,14 +876,14 @@ class Pt extends ut {
871
876
  y: e,
872
877
  color: o,
873
878
  pixelRatio: s,
874
- phase: l,
879
+ phase: a,
875
880
  alpha: r = 1
876
881
  }) {
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();
882
+ const m = 3 * s, h = 0.4 + 0.6 * Math.abs(Math.sin(a * 2 * Math.PI)), p = m + 4 * s * h, c = r < 1;
883
+ c && (t.save(), t.globalAlpha *= r), t.beginPath(), t.arc(i, e, p, 0, Math.PI * 2), t.fillStyle = C(o, h * 0.3), t.fill(), t.beginPath(), t.arc(i, e, m, 0, Math.PI * 2), t.fillStyle = o, t.fill(), c && t.restore();
879
884
  }
880
885
  }
881
- const Bt = {
886
+ const Lt = {
882
887
  type: "line",
883
888
  xTypes: ["time", "numeric", "category"],
884
889
  create: ({ theme: y, layerCount: t }, i) => new Pt(t, {
@@ -889,5 +894,5 @@ const Bt = {
889
894
  };
890
895
  export {
891
896
  Pt as LineRenderer,
892
- Bt as LineSeriesDef
897
+ Lt as LineSeriesDef
893
898
  };